<!DOCTYPE html><html><head>
      <title>&#x73A9;&#x8F6C; AOSP &#x7BC7;</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      
      <link rel="stylesheet" href="file:///c:\Users\ahao\.vscode\extensions\shd101wyy.markdown-preview-enhanced-0.6.8\node_modules\@shd101wyy\mume\dependencies\katex\katex.min.css">
      
      
      
      
      
      
      
      
      
      <style>
      /**
 * prism.js Github theme based on GitHub's theme.
 * @author Sam Clarke
 */
code[class*="language-"],
pre[class*="language-"] {
  color: #333;
  background: none;
  font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
  text-align: left;
  white-space: pre;
  word-spacing: normal;
  word-break: normal;
  word-wrap: normal;
  line-height: 1.4;

  -moz-tab-size: 8;
  -o-tab-size: 8;
  tab-size: 8;

  -webkit-hyphens: none;
  -moz-hyphens: none;
  -ms-hyphens: none;
  hyphens: none;
}

/* Code blocks */
pre[class*="language-"] {
  padding: .8em;
  overflow: auto;
  /* border: 1px solid #ddd; */
  border-radius: 3px;
  /* background: #fff; */
  background: #f5f5f5;
}

/* Inline code */
:not(pre) > code[class*="language-"] {
  padding: .1em;
  border-radius: .3em;
  white-space: normal;
  background: #f5f5f5;
}

.token.comment,
.token.blockquote {
  color: #969896;
}

.token.cdata {
  color: #183691;
}

.token.doctype,
.token.punctuation,
.token.variable,
.token.macro.property {
  color: #333;
}

.token.operator,
.token.important,
.token.keyword,
.token.rule,
.token.builtin {
  color: #a71d5d;
}

.token.string,
.token.url,
.token.regex,
.token.attr-value {
  color: #183691;
}

.token.property,
.token.number,
.token.boolean,
.token.entity,
.token.atrule,
.token.constant,
.token.symbol,
.token.command,
.token.code {
  color: #0086b3;
}

.token.tag,
.token.selector,
.token.prolog {
  color: #63a35c;
}

.token.function,
.token.namespace,
.token.pseudo-element,
.token.class,
.token.class-name,
.token.pseudo-class,
.token.id,
.token.url-reference .token.variable,
.token.attr-name {
  color: #795da3;
}

.token.entity {
  cursor: help;
}

.token.title,
.token.title .token.punctuation {
  font-weight: bold;
  color: #1d3e81;
}

.token.list {
  color: #ed6a43;
}

.token.inserted {
  background-color: #eaffea;
  color: #55a532;
}

.token.deleted {
  background-color: #ffecec;
  color: #bd2c00;
}

.token.bold {
  font-weight: bold;
}

.token.italic {
  font-style: italic;
}


/* JSON */
.language-json .token.property {
  color: #183691;
}

.language-markup .token.tag .token.punctuation {
  color: #333;
}

/* CSS */
code.language-css,
.language-css .token.function {
  color: #0086b3;
}

/* YAML */
.language-yaml .token.atrule {
  color: #63a35c;
}

code.language-yaml {
  color: #183691;
}

/* Ruby */
.language-ruby .token.function {
  color: #333;
}

/* Markdown */
.language-markdown .token.url {
  color: #795da3;
}

/* Makefile */
.language-makefile .token.symbol {
  color: #795da3;
}

.language-makefile .token.variable {
  color: #183691;
}

.language-makefile .token.builtin {
  color: #0086b3;
}

/* Bash */
.language-bash .token.keyword {
  color: #0086b3;
}

/* highlight */
pre[data-line] {
  position: relative;
  padding: 1em 0 1em 3em;
}
pre[data-line] .line-highlight-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  background-color: transparent;
  display: block;
  width: 100%;
}

pre[data-line] .line-highlight {
  position: absolute;
  left: 0;
  right: 0;
  padding: inherit 0;
  margin-top: 1em;
  background: hsla(24, 20%, 50%,.08);
  background: linear-gradient(to right, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0));
  pointer-events: none;
  line-height: inherit;
  white-space: pre;
}

pre[data-line] .line-highlight:before, 
pre[data-line] .line-highlight[data-end]:after {
  content: attr(data-start);
  position: absolute;
  top: .4em;
  left: .6em;
  min-width: 1em;
  padding: 0 .5em;
  background-color: hsla(24, 20%, 50%,.4);
  color: hsl(24, 20%, 95%);
  font: bold 65%/1.5 sans-serif;
  text-align: center;
  vertical-align: .3em;
  border-radius: 999px;
  text-shadow: none;
  box-shadow: 0 1px white;
}

pre[data-line] .line-highlight[data-end]:after {
  content: attr(data-end);
  top: auto;
  bottom: .4em;
}html body{font-family:"Helvetica Neue",Helvetica,"Segoe UI",Arial,freesans,sans-serif;font-size:16px;line-height:1.6;color:#333;background-color:#fff;overflow:initial;box-sizing:border-box;word-wrap:break-word}html body>:first-child{margin-top:0}html body h1,html body h2,html body h3,html body h4,html body h5,html body h6{line-height:1.2;margin-top:1em;margin-bottom:16px;color:#000}html body h1{font-size:2.25em;font-weight:300;padding-bottom:.3em}html body h2{font-size:1.75em;font-weight:400;padding-bottom:.3em}html body h3{font-size:1.5em;font-weight:500}html body h4{font-size:1.25em;font-weight:600}html body h5{font-size:1.1em;font-weight:600}html body h6{font-size:1em;font-weight:600}html body h1,html body h2,html body h3,html body h4,html body h5{font-weight:600}html body h5{font-size:1em}html body h6{color:#5c5c5c}html body strong{color:#000}html body del{color:#5c5c5c}html body a:not([href]){color:inherit;text-decoration:none}html body a{color:#08c;text-decoration:none}html body a:hover{color:#00a3f5;text-decoration:none}html body img{max-width:100%}html body>p{margin-top:0;margin-bottom:16px;word-wrap:break-word}html body>ul,html body>ol{margin-bottom:16px}html body ul,html body ol{padding-left:2em}html body ul.no-list,html body ol.no-list{padding:0;list-style-type:none}html body ul ul,html body ul ol,html body ol ol,html body ol ul{margin-top:0;margin-bottom:0}html body li{margin-bottom:0}html body li.task-list-item{list-style:none}html body li>p{margin-top:0;margin-bottom:0}html body .task-list-item-checkbox{margin:0 .2em .25em -1.8em;vertical-align:middle}html body .task-list-item-checkbox:hover{cursor:pointer}html body blockquote{margin:16px 0;font-size:inherit;padding:0 15px;color:#5c5c5c;background-color:#f0f0f0;border-left:4px solid #d6d6d6}html body blockquote>:first-child{margin-top:0}html body blockquote>:last-child{margin-bottom:0}html body hr{height:4px;margin:32px 0;background-color:#d6d6d6;border:0 none}html body table{margin:10px 0 15px 0;border-collapse:collapse;border-spacing:0;display:block;width:100%;overflow:auto;word-break:normal;word-break:keep-all}html body table th{font-weight:bold;color:#000}html body table td,html body table th{border:1px solid #d6d6d6;padding:6px 13px}html body dl{padding:0}html body dl dt{padding:0;margin-top:16px;font-size:1em;font-style:italic;font-weight:bold}html body dl dd{padding:0 16px;margin-bottom:16px}html body code{font-family:Menlo,Monaco,Consolas,'Courier New',monospace;font-size:.85em !important;color:#000;background-color:#f0f0f0;border-radius:3px;padding:.2em 0}html body code::before,html body code::after{letter-spacing:-0.2em;content:"\00a0"}html body pre>code{padding:0;margin:0;font-size:.85em !important;word-break:normal;white-space:pre;background:transparent;border:0}html body .highlight{margin-bottom:16px}html body .highlight pre,html body pre{padding:1em;overflow:auto;font-size:.85em !important;line-height:1.45;border:#d6d6d6;border-radius:3px}html body .highlight pre{margin-bottom:0;word-break:normal}html body pre code,html body pre tt{display:inline;max-width:initial;padding:0;margin:0;overflow:initial;line-height:inherit;word-wrap:normal;background-color:transparent;border:0}html body pre code:before,html body pre tt:before,html body pre code:after,html body pre tt:after{content:normal}html body p,html body blockquote,html body ul,html body ol,html body dl,html body pre{margin-top:0;margin-bottom:16px}html body kbd{color:#000;border:1px solid #d6d6d6;border-bottom:2px solid #c7c7c7;padding:2px 4px;background-color:#f0f0f0;border-radius:3px}@media print{html body{background-color:#fff}html body h1,html body h2,html body h3,html body h4,html body h5,html body h6{color:#000;page-break-after:avoid}html body blockquote{color:#5c5c5c}html body pre{page-break-inside:avoid}html body table{display:table}html body img{display:block;max-width:100%;max-height:100%}html body pre,html body code{word-wrap:break-word;white-space:pre}}.markdown-preview{width:100%;height:100%;box-sizing:border-box}.markdown-preview .pagebreak,.markdown-preview .newpage{page-break-before:always}.markdown-preview pre.line-numbers{position:relative;padding-left:3.8em;counter-reset:linenumber}.markdown-preview pre.line-numbers>code{position:relative}.markdown-preview pre.line-numbers .line-numbers-rows{position:absolute;pointer-events:none;top:1em;font-size:100%;left:0;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.markdown-preview pre.line-numbers .line-numbers-rows>span{pointer-events:none;display:block;counter-increment:linenumber}.markdown-preview pre.line-numbers .line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.8em;text-align:right}.markdown-preview .mathjax-exps .MathJax_Display{text-align:center !important}.markdown-preview:not([for="preview"]) .code-chunk .btn-group{display:none}.markdown-preview:not([for="preview"]) .code-chunk .status{display:none}.markdown-preview:not([for="preview"]) .code-chunk .output-div{margin-bottom:16px}.markdown-preview .md-toc{padding:0}.markdown-preview .md-toc .md-toc-link-wrapper .md-toc-link{display:inline;padding:.25rem 0}.markdown-preview .md-toc .md-toc-link-wrapper .md-toc-link p,.markdown-preview .md-toc .md-toc-link-wrapper .md-toc-link div{display:inline}.markdown-preview .md-toc .md-toc-link-wrapper.highlighted .md-toc-link{font-weight:800}.scrollbar-style::-webkit-scrollbar{width:8px}.scrollbar-style::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}.scrollbar-style::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,0.66);border:4px solid rgba(150,150,150,0.66);background-clip:content-box}html body[for="html-export"]:not([data-presentation-mode]){position:relative;width:100%;height:100%;top:0;left:0;margin:0;padding:0;overflow:auto}html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{position:relative;top:0}@media screen and (min-width:914px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{padding:2em calc(50% - 457px + 2em)}}@media screen and (max-width:914px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{font-size:14px !important;padding:1em}}@media print{html body[for="html-export"]:not([data-presentation-mode]) #sidebar-toc-btn{display:none}}html body[for="html-export"]:not([data-presentation-mode]) #sidebar-toc-btn{position:fixed;bottom:8px;left:8px;font-size:28px;cursor:pointer;color:inherit;z-index:99;width:32px;text-align:center;opacity:.4}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] #sidebar-toc-btn{opacity:1}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc{position:fixed;top:0;left:0;width:300px;height:100%;padding:32px 0 48px 0;font-size:14px;box-shadow:0 0 4px rgba(150,150,150,0.33);box-sizing:border-box;overflow:auto;background-color:inherit}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar{width:8px}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,0.66);border:4px solid rgba(150,150,150,0.66);background-clip:content-box}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc a{text-decoration:none}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc .md-toc{padding:0 16px}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc .md-toc .md-toc-link-wrapper .md-toc-link{display:inline;padding:.25rem 0}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc .md-toc .md-toc-link-wrapper .md-toc-link p,html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc .md-toc .md-toc-link-wrapper .md-toc-link div{display:inline}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc .md-toc .md-toc-link-wrapper.highlighted .md-toc-link{font-weight:800}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{left:300px;width:calc(100% -  300px);padding:2em calc(50% - 457px -  300px/2);margin:0;box-sizing:border-box}@media screen and (max-width:1274px){html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{width:100%}}html body[for="html-export"]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .markdown-preview{left:50%;transform:translateX(-50%)}html body[for="html-export"]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .md-sidebar-toc{display:none}
/* Please visit the URL below for more information: */
/*   https://shd101wyy.github.io/markdown-preview-enhanced/#/customize-css */

      </style>
    </head>
    <body for="html-export">
      <div class="mume markdown-preview  ">
      <div class="md-toc">
<details style="padding:0;;padding-left:0px;" open>
        <summary class="md-toc-link-wrapper">
          <a href="#&#x5199;&#x7ED9;&#x5E94;&#x7528;&#x5F00;&#x53D1;&#x7684;-android-framework-&#x6559;&#x7A0B;&#x73A9;&#x8F6C;-aosp-&#x7BC7;" class="md-toc-link"><p>&#x5199;&#x7ED9;&#x5E94;&#x7528;&#x5F00;&#x53D1;&#x7684; Android Framework &#x6559;&#x7A0B;&#x2014;&#x2014;&#x73A9;&#x8F6C; AOSP &#x7BC7;</p>
</a>
          </summary>
        <div>
          <details style="padding:0;;padding-left:24px;" open>
        <summary class="md-toc-link-wrapper">
          <a href="#&#x7B2C;&#x4E00;&#x7AE0;-aosp-&#x6781;&#x901F;&#x4E0A;&#x624B;" class="md-toc-link"><p>&#x7B2C;&#x4E00;&#x7AE0; AOSP &#x6781;&#x901F;&#x4E0A;&#x624B;</p>
</a>
          </summary>
        <div>
          <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#1-&#x786C;&#x4EF6;&#x8981;&#x6C42;" class="md-toc-link">
            <ol>
<li>&#x786C;&#x4EF6;&#x8981;&#x6C42;</li>
</ol>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#2-&#x865A;&#x62DF;&#x673A;&#x5B89;&#x88C5;" class="md-toc-link">
            <ol start="2">
<li>&#x865A;&#x62DF;&#x673A;&#x5B89;&#x88C5;</li>
</ol>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#3-&#x5F00;&#x53D1;&#x73AF;&#x5883;&#x642D;&#x5EFA;" class="md-toc-link">
            <ol start="3">
<li>&#x5F00;&#x53D1;&#x73AF;&#x5883;&#x642D;&#x5EFA;</li>
</ol>

          </a></div><details style="padding:0;;padding-left:24px;" open>
        <summary class="md-toc-link-wrapper">
          <a href="#4-&#x4E0B;&#x8F7D;&#x7F16;&#x8BD1;&#x6E90;&#x7801;" class="md-toc-link"><ol start="4">
<li>&#x4E0B;&#x8F7D;&#x7F16;&#x8BD1;&#x6E90;&#x7801;</li>
</ol>
</a>
          </summary>
        <div>
          <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#41-&#x4E0B;&#x8F7D;-repo-&#x5DE5;&#x5177;" class="md-toc-link">
            <p>4.1 &#x4E0B;&#x8F7D; repo &#x5DE5;&#x5177;</p>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#42-&#x521D;&#x59CB;&#x5316;&#x4ED3;&#x5E93;&#x5E76;&#x540C;&#x6B65;&#x8FDC;&#x7A0B;&#x4EE3;&#x7801;" class="md-toc-link">
            <p>4.2 &#x521D;&#x59CB;&#x5316;&#x4ED3;&#x5E93;&#x5E76;&#x540C;&#x6B65;&#x8FDC;&#x7A0B;&#x4EE3;&#x7801;</p>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#43-&#x7F16;&#x8BD1;&#x6E90;&#x7801;" class="md-toc-link">
            <p>4.3 &#x7F16;&#x8BD1;&#x6E90;&#x7801;</p>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#44-&#x8FD0;&#x884C;&#x6A21;&#x62DF;&#x5668;" class="md-toc-link">
            <p>4.4 &#x8FD0;&#x884C;&#x6A21;&#x62DF;&#x5668;</p>

          </a></div>
        </div>
      </details>
    <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#5-&#x4ECE;&#x4E00;&#x4E2A;&#x7B80;&#x5355;&#x7684;&#x5B9E;&#x9645;&#x5F00;&#x53D1;&#x9700;&#x6C42;&#x4F53;&#x9A8C;-framework-&#x5F00;&#x53D1;" class="md-toc-link">
            <ol start="5">
<li>&#x4ECE;&#x4E00;&#x4E2A;&#x7B80;&#x5355;&#x7684;&#x5B9E;&#x9645;&#x5F00;&#x53D1;&#x9700;&#x6C42;&#x4F53;&#x9A8C; Framework &#x5F00;&#x53D1;</li>
</ol>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#6-&#x603B;&#x7ED3;" class="md-toc-link">
            <ol start="6">
<li>&#x603B;&#x7ED3;</li>
</ol>

          </a></div>
        </div>
      </details>
    <details style="padding:0;;padding-left:24px;" open>
        <summary class="md-toc-link-wrapper">
          <a href="#&#x7B2C;&#x4E8C;&#x7AE0;-&#x7CFB;&#x7EDF;&#x5F00;&#x53D1;&#x5DE5;&#x5177;&#x63A8;&#x8350;" class="md-toc-link"><p>&#x7B2C;&#x4E8C;&#x7AE0; &#x7CFB;&#x7EDF;&#x5F00;&#x53D1;&#x5DE5;&#x5177;&#x63A8;&#x8350;</p>
</a>
          </summary>
        <div>
          <details style="padding:0;;padding-left:24px;" open>
        <summary class="md-toc-link-wrapper">
          <a href="#1-ssh-&#x670D;&#x52A1;&#x4E0E;-tabby-terminal" class="md-toc-link"><ol>
<li>SSH &#x670D;&#x52A1;&#x4E0E; Tabby Terminal</li>
</ol>
</a>
          </summary>
        <div>
          <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#11-&#x914D;&#x7F6E;-ubuntu-ssh-&#x670D;&#x52A1;" class="md-toc-link">
            <p>1.1 &#x914D;&#x7F6E; Ubuntu ssh &#x670D;&#x52A1;</p>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#12-ssh-&#x5BA2;&#x6237;&#x7AEF;-tabby-terminal" class="md-toc-link">
            <p>1.2 ssh &#x5BA2;&#x6237;&#x7AEF; Tabby Terminal</p>

          </a></div>
        </div>
      </details>
    <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#2-vim" class="md-toc-link">
            <ol start="2">
<li>vim</li>
</ol>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#3-find--grep-&#x547D;&#x4EE4;" class="md-toc-link">
            <ol start="3">
<li>find + grep &#x547D;&#x4EE4;</li>
</ol>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#4-samba-&#x670D;&#x52A1;&#x5668;&#x642D;&#x5EFA;" class="md-toc-link">
            <ol start="4">
<li>Samba &#x670D;&#x52A1;&#x5668;&#x642D;&#x5EFA;</li>
</ol>

          </a></div><details style="padding:0;;padding-left:24px;" open>
        <summary class="md-toc-link-wrapper">
          <a href="#5-vscode" class="md-toc-link"><ol start="5">
<li>VSCode</li>
</ol>
</a>
          </summary>
        <div>
          <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#51-ubuntu-&#x672C;&#x673A;&#x4F7F;&#x7528;" class="md-toc-link">
            <p>5.1 Ubuntu &#x672C;&#x673A;&#x4F7F;&#x7528;</p>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#52-&#x8FDC;&#x7A0B;&#x4F7F;&#x7528;" class="md-toc-link">
            <p>5.2 &#x8FDC;&#x7A0B;&#x4F7F;&#x7528;</p>

          </a></div>
        </div>
      </details>
    <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#6-adb" class="md-toc-link">
            <ol start="6">
<li>adb</li>
</ol>

          </a></div>
        </div>
      </details>
    <details style="padding:0;;padding-left:24px;" open>
        <summary class="md-toc-link-wrapper">
          <a href="#&#x7B2C;&#x4E09;&#x7AE0;-&#x6DFB;&#x52A0;-product" class="md-toc-link"><p>&#x7B2C;&#x4E09;&#x7AE0; &#x6DFB;&#x52A0; Product</p>
</a>
          </summary>
        <div>
          <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#1-&#x4EC0;&#x4E48;&#x662F;-product" class="md-toc-link">
            <ol>
<li>&#x4EC0;&#x4E48;&#x662F; Product</li>
</ol>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#2-aosp-&#x4E2D;&#x9884;&#x5236;&#x7684;-product" class="md-toc-link">
            <ol start="2">
<li>AOSP &#x4E2D;&#x9884;&#x5236;&#x7684; Product</li>
</ol>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#3-&#x6DFB;&#x52A0;&#x81EA;&#x5DF1;&#x7684;-product" class="md-toc-link">
            <ol start="3">
<li>&#x6DFB;&#x52A0;&#x81EA;&#x5DF1;&#x7684; Product</li>
</ol>

          </a></div>
        </div>
      </details>
    <details style="padding:0;;padding-left:24px;" open>
        <summary class="md-toc-link-wrapper">
          <a href="#&#x7B2C;&#x56DB;&#x7AE0;-&#x6DFB;&#x52A0;&#x53EF;&#x6267;&#x884C;&#x7A0B;&#x5E8F;" class="md-toc-link"><p>&#x7B2C;&#x56DB;&#x7AE0; &#x6DFB;&#x52A0;&#x53EF;&#x6267;&#x884C;&#x7A0B;&#x5E8F;</p>
</a>
          </summary>
        <div>
          <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#1-arm--android-&#x884C;&#x4E1A;&#x6D41;&#x7A0B;&#x4E0E;-android-&#x5206;&#x533A;" class="md-toc-link">
            <ol>
<li>ARM + Android &#x884C;&#x4E1A;&#x6D41;&#x7A0B;&#x4E0E; Android &#x5206;&#x533A;</li>
</ol>

          </a></div><details style="padding:0;;padding-left:24px;" open>
        <summary class="md-toc-link-wrapper">
          <a href="#2-&#x52A8;&#x624B;&#x5728;&#x7CFB;&#x7EDF;&#x6E90;&#x7801;&#x4E2D;&#x6DFB;&#x52A0;&#x4E00;&#x4E2A;-cc-&#x53EF;&#x6267;&#x884C;&#x7A0B;&#x5E8F;" class="md-toc-link"><ol start="2">
<li>&#x52A8;&#x624B;&#x5728;&#x7CFB;&#x7EDF;&#x6E90;&#x7801;&#x4E2D;&#x6DFB;&#x52A0;&#x4E00;&#x4E2A; C/C++ &#x53EF;&#x6267;&#x884C;&#x7A0B;&#x5E8F;</li>
</ol>
</a>
          </summary>
        <div>
          <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#21-&#x6E90;&#x7801;&#x6DFB;&#x52A0;" class="md-toc-link">
            <p>2.1 &#x6E90;&#x7801;&#x6DFB;&#x52A0;</p>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#22-&#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;&#x6DFB;&#x52A0;" class="md-toc-link">
            <p>2.2 &#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;&#x6DFB;&#x52A0;</p>

          </a></div>
        </div>
      </details>
    <details style="padding:0;;padding-left:24px;" open>
        <summary class="md-toc-link-wrapper">
          <a href="#3-&#x6DFB;&#x52A0;-java-&#x53EF;&#x6267;&#x884C;&#x7A0B;&#x5E8F;" class="md-toc-link"><ol start="3">
<li>&#x6DFB;&#x52A0; Java &#x53EF;&#x6267;&#x884C;&#x7A0B;&#x5E8F;</li>
</ol>
</a>
          </summary>
        <div>
          <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#31-&#x6E90;&#x7801;&#x6DFB;&#x52A0;" class="md-toc-link">
            <p>3.1 &#x6E90;&#x7801;&#x6DFB;&#x52A0;</p>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#32-&#x53EF;&#x6267;&#x884C;-jar-&#x5305;&#x6DFB;&#x52A0;" class="md-toc-link">
            <p>3.2 &#x53EF;&#x6267;&#x884C; jar &#x5305;&#x6DFB;&#x52A0;</p>

          </a></div>
        </div>
      </details>
    <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#&#x603B;&#x7ED3;" class="md-toc-link">
            <p>&#x603B;&#x7ED3;</p>

          </a></div>
        </div>
      </details>
    <details style="padding:0;;padding-left:24px;" open>
        <summary class="md-toc-link-wrapper">
          <a href="#&#x7B2C;&#x4E94;&#x7AE0;-&#x6DFB;&#x52A0;-cc-java-&#x5E93;" class="md-toc-link"><p>&#x7B2C;&#x4E94;&#x7AE0; &#x6DFB;&#x52A0; C/C++&#x3001;Java &#x5E93;</p>
</a>
          </summary>
        <div>
          <details style="padding:0;;padding-left:24px;" open>
        <summary class="md-toc-link-wrapper">
          <a href="#1&#x6DFB;&#x52A0;-cc-&#x7A0B;&#x5E8F;&#x5E93;" class="md-toc-link"><p>1.&#x6DFB;&#x52A0; C/C++ &#x7A0B;&#x5E8F;&#x5E93;</p>
</a>
          </summary>
        <div>
          <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#11-&#x6E90;&#x7801;&#x65B9;&#x5F0F;&#x6DFB;&#x52A0;" class="md-toc-link">
            <p>1.1 &#x6E90;&#x7801;&#x65B9;&#x5F0F;&#x6DFB;&#x52A0;</p>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#12-so-&#x5305;&#x65B9;&#x5F0F;&#x6DFB;&#x52A0;" class="md-toc-link">
            <p>1.2 so &#x5305;&#x65B9;&#x5F0F;&#x6DFB;&#x52A0;</p>

          </a></div>
        </div>
      </details>
    <details style="padding:0;;padding-left:24px;" open>
        <summary class="md-toc-link-wrapper">
          <a href="#2-&#x6DFB;&#x52A0;-java-&#x5E93;" class="md-toc-link"><ol start="2">
<li>&#x6DFB;&#x52A0; Java &#x5E93;</li>
</ol>
</a>
          </summary>
        <div>
          <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#21-&#x6E90;&#x7801;&#x65B9;&#x5F0F;&#x6DFB;&#x52A0;" class="md-toc-link">
            <p>2.1 &#x6E90;&#x7801;&#x65B9;&#x5F0F;&#x6DFB;&#x52A0;</p>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#22-jar-&#x5305;&#x65B9;&#x5F0F;&#x6DFB;&#x52A0;" class="md-toc-link">
            <p>2.2 Jar &#x5305;&#x65B9;&#x5F0F;&#x6DFB;&#x52A0;</p>

          </a></div>
        </div>
      </details>
    
        </div>
      </details>
    <details style="padding:0;;padding-left:24px;" open>
        <summary class="md-toc-link-wrapper">
          <a href="#&#x7B2C;&#x516D;&#x7AE0;-&#x6DFB;&#x52A0;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4E0E;&#x5220;&#x9664;&#x5DF2;&#x6709;&#x6A21;&#x5757;" class="md-toc-link"><p>&#x7B2C;&#x516D;&#x7AE0; &#x6DFB;&#x52A0;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4E0E;&#x5220;&#x9664;&#x5DF2;&#x6709;&#x6A21;&#x5757;</p>
</a>
          </summary>
        <div>
          <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#1-&#x6DFB;&#x52A0;&#x914D;&#x7F6E;&#x6587;&#x4EF6;" class="md-toc-link">
            <ol>
<li>&#x6DFB;&#x52A0;&#x914D;&#x7F6E;&#x6587;&#x4EF6;</li>
</ol>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#2-&#x5220;&#x9664;&#x5DF2;&#x6709;&#x6A21;&#x5757;" class="md-toc-link">
            <ol start="2">
<li>&#x5220;&#x9664;&#x5DF2;&#x6709;&#x6A21;&#x5757;</li>
</ol>

          </a></div>
        </div>
      </details>
    <details style="padding:0;;padding-left:24px;" open>
        <summary class="md-toc-link-wrapper">
          <a href="#&#x7B2C;&#x4E03;&#x7AE0;-&#x6DFB;&#x52A0;&#x7CFB;&#x7EDF;-app-&#x6E90;&#x7801;" class="md-toc-link"><p>&#x7B2C;&#x4E03;&#x7AE0; &#x6DFB;&#x52A0;&#x7CFB;&#x7EDF; App &#x6E90;&#x7801;</p>
</a>
          </summary>
        <div>
          <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#1-&#x5982;&#x4F55;&#x65B0;&#x5EFA;&#x4E00;&#x4E2A;&#x7CFB;&#x7EDF;-app-&#x9879;&#x76EE;" class="md-toc-link">
            <ol>
<li>&#x5982;&#x4F55;&#x65B0;&#x5EFA;&#x4E00;&#x4E2A;&#x7CFB;&#x7EDF; App &#x9879;&#x76EE;</li>
</ol>

          </a></div><details style="padding:0;;padding-left:24px;" open>
        <summary class="md-toc-link-wrapper">
          <a href="#2-&#x7CFB;&#x7EDF;-app-&#x4E0E;-&#x666E;&#x901A;-app-&#x7684;&#x5DEE;&#x5F02;" class="md-toc-link"><ol start="2">
<li>&#x7CFB;&#x7EDF; App &#x4E0E; &#x666E;&#x901A; App &#x7684;&#x5DEE;&#x5F02;</li>
</ol>
</a>
          </summary>
        <div>
          <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#21-&#x7CFB;&#x7EDF;-app-&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x66F4;&#x591A;&#x7684;-api" class="md-toc-link">
            <p>2.1 &#x7CFB;&#x7EDF; App &#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x66F4;&#x591A;&#x7684; api</p>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#22-&#x7CFB;&#x7EDF;-app-&#x7684;&#x7B7E;&#x540D;" class="md-toc-link">
            <p>2.2 &#x7CFB;&#x7EDF; App &#x7684;&#x7B7E;&#x540D;</p>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#23-&#x7CFB;&#x7EDF;-app-&#x80FD;&#x4F7F;&#x7528;&#x66F4;&#x591A;&#x7684;&#x6743;&#x9650;" class="md-toc-link">
            <p>2.3 &#x7CFB;&#x7EDF; App &#x80FD;&#x4F7F;&#x7528;&#x66F4;&#x591A;&#x7684;&#x6743;&#x9650;</p>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#24-&#x7CFB;&#x7EDF;-app-&#x80FD;&#x66F4;&#x8F7B;&#x677E;&#x5730;&#x5B9E;&#x73B0;&#x8FDB;&#x7A0B;&#x4FDD;&#x6D3B;" class="md-toc-link">
            <p>2.4 &#x7CFB;&#x7EDF; App &#x80FD;&#x66F4;&#x8F7B;&#x677E;&#x5730;&#x5B9E;&#x73B0;&#x8FDB;&#x7A0B;&#x4FDD;&#x6D3B;</p>

          </a></div>
        </div>
      </details>
    <details style="padding:0;;padding-left:24px;" open>
        <summary class="md-toc-link-wrapper">
          <a href="#3-&#x7CFB;&#x7EDF;-app-&#x6DFB;&#x52A0;&#x4F9D;&#x8D56;" class="md-toc-link"><ol start="3">
<li>&#x7CFB;&#x7EDF; App &#x6DFB;&#x52A0;&#x4F9D;&#x8D56;</li>
</ol>
</a>
          </summary>
        <div>
          <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#31-&#x6DFB;&#x52A0;-aosp-&#x4E2D;&#x5DF2;&#x6709;&#x7684;&#x5E93;" class="md-toc-link">
            <p>3.1 &#x6DFB;&#x52A0; AOSP &#x4E2D;&#x5DF2;&#x6709;&#x7684;&#x5E93;</p>

          </a></div><details style="padding:0;;padding-left:24px;" open>
        <summary class="md-toc-link-wrapper">
          <a href="#32-&#x81EA;&#x5DF1;&#x7ED9;-aosp-&#x6DFB;&#x52A0;&#x5E93;" class="md-toc-link"><p>3.2 &#x81EA;&#x5DF1;&#x7ED9; AOSP &#x6DFB;&#x52A0;&#x5E93;</p>
</a>
          </summary>
        <div>
          <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#321-java-&#x5E93;&#x6E90;&#x7801;&#x5F15;&#x5165;" class="md-toc-link">
            <p>3.2.1 java &#x5E93;&#x6E90;&#x7801;&#x5F15;&#x5165;</p>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#322-java-&#x5E93;&#x4EE5;-jar-&#x5305;&#x5F62;&#x5F0F;&#x5F15;&#x5165;" class="md-toc-link">
            <p>3.2.2 java &#x5E93;&#x4EE5; jar &#x5305;&#x5F62;&#x5F0F;&#x5F15;&#x5165;</p>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#323-android-&#x5E93;&#x6E90;&#x7801;&#x5F15;&#x5165;" class="md-toc-link">
            <p>3.2.3 Android &#x5E93;&#x6E90;&#x7801;&#x5F15;&#x5165;</p>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#324-android-&#x5E93;&#x4EE5;-aar-&#x5305;&#x5F62;&#x5F0F;&#x5F15;&#x5165;" class="md-toc-link">
            <p>3.2.4 Android &#x5E93;&#x4EE5; aar &#x5305;&#x5F62;&#x5F0F;&#x5F15;&#x5165;</p>

          </a></div>
        </div>
      </details>
    
        </div>
      </details>
    <details style="padding:0;;padding-left:24px;" open>
        <summary class="md-toc-link-wrapper">
          <a href="#4-jni-&#x9879;&#x76EE;" class="md-toc-link"><ol start="4">
<li>JNI &#x9879;&#x76EE;</li>
</ol>
</a>
          </summary>
        <div>
          <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#41-&#x521B;&#x5EFA;-jni-&#x9879;&#x76EE;" class="md-toc-link">
            <p>4.1 &#x521B;&#x5EFA; JNI &#x9879;&#x76EE;</p>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#42-jniapp-&#x94FE;&#x63A5;&#x81EA;&#x5B9A;&#x4E49;&#x5E93;" class="md-toc-link">
            <p>4.2 JNIApp &#x94FE;&#x63A5;&#x81EA;&#x5B9A;&#x4E49;&#x5E93;</p>

          </a></div>
        </div>
      </details>
    
        </div>
      </details>
    <details style="padding:0;;padding-left:24px;" open>
        <summary class="md-toc-link-wrapper">
          <a href="#&#x7B2C;&#x516B;&#x7AE0;-&#x4F7F;&#x7528;-android-studio-&#x5F00;&#x53D1;&#x7CFB;&#x7EDF;-app" class="md-toc-link"><p>&#x7B2C;&#x516B;&#x7AE0; &#x4F7F;&#x7528; Android Studio &#x5F00;&#x53D1;&#x7CFB;&#x7EDF; App</p>
</a>
          </summary>
        <div>
          <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#1-&#x7F16;&#x8BD1;-framework-&#x6A21;&#x5757;" class="md-toc-link">
            <ol>
<li>&#x7F16;&#x8BD1; framework &#x6A21;&#x5757;</li>
</ol>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#2-&#x521B;&#x5EFA;&#x7CFB;&#x7EDF;-app-&#x9879;&#x76EE;" class="md-toc-link">
            <ol start="2">
<li>&#x521B;&#x5EFA;&#x7CFB;&#x7EDF; App &#x9879;&#x76EE;</li>
</ol>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#3-&#x7CFB;&#x7EDF;-app-&#x7684;&#x7F16;&#x8BD1;&#x8FD0;&#x884C;" class="md-toc-link">
            <ol start="3">
<li>&#x7CFB;&#x7EDF; APP &#x7684;&#x7F16;&#x8BD1;&#x8FD0;&#x884C;</li>
</ol>

          </a></div><details style="padding:0;;padding-left:24px;" open>
        <summary class="md-toc-link-wrapper">
          <a href="#4-&#x7CFB;&#x7EDF;-app-&#x7279;&#x70B9;" class="md-toc-link"><ol start="4">
<li>&#x7CFB;&#x7EDF; App &#x7279;&#x70B9;</li>
</ol>
</a>
          </summary>
        <div>
          <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#41-&#x7CFB;&#x7EDF;-app-&#x53EF;&#x4EE5;&#x6267;&#x884C;&#x4E09;&#x65B9;-app-&#x4E0D;&#x80FD;&#x6267;&#x884C;&#x7684;-api" class="md-toc-link">
            <p>4.1 &#x7CFB;&#x7EDF; app &#x53EF;&#x4EE5;&#x6267;&#x884C;&#x4E09;&#x65B9; App &#x4E0D;&#x80FD;&#x6267;&#x884C;&#x7684; Api</p>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#42-&#x8FDB;&#x7A0B;&#x4FDD;&#x6D3B;" class="md-toc-link">
            <p>4.2 &#x8FDB;&#x7A0B;&#x4FDD;&#x6D3B;</p>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#43-&#x7CFB;&#x7EDF;-app-&#x6743;&#x9650;" class="md-toc-link">
            <p>4.3 &#x7CFB;&#x7EDF; App &#x6743;&#x9650;</p>

          </a></div>
        </div>
      </details>
    
        </div>
      </details>
    <details style="padding:0;;padding-left:24px;" open>
        <summary class="md-toc-link-wrapper">
          <a href="#&#x7B2C;&#x4E5D;&#x7AE0;-seandroid-&#x4F7F;&#x7528;&#x6781;&#x901F;&#x4E0A;&#x624B;" class="md-toc-link"><p>&#x7B2C;&#x4E5D;&#x7AE0; SeAndroid &#x4F7F;&#x7528;&#x6781;&#x901F;&#x4E0A;&#x624B;</p>
</a>
          </summary>
        <div>
          <details style="padding:0;;padding-left:24px;" open>
        <summary class="md-toc-link-wrapper">
          <a href="#1-&#x57FA;&#x672C;&#x6982;&#x5FF5;" class="md-toc-link"><ol>
<li>&#x57FA;&#x672C;&#x6982;&#x5FF5;</li>
</ol>
</a>
          </summary>
        <div>
          <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#11-&#x8D44;&#x6E90;&#x7684;&#x540D;&#x5B57;&#x5B89;&#x5168;&#x4E0A;&#x4E0B;&#x6587;security-context" class="md-toc-link">
            <p>1.1 &#x8D44;&#x6E90;&#x7684;&#x540D;&#x5B57;&#x2014;&#x2014;&#x5B89;&#x5168;&#x4E0A;&#x4E0B;&#x6587;&#xFF08;security context&#xFF09;</p>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#12-&#x5B9A;&#x4E49;&#x8D44;&#x6E90;&#x7684;&#x4F7F;&#x7528;&#x89C4;&#x5219;" class="md-toc-link">
            <p>1.2 &#x5B9A;&#x4E49;&#x8D44;&#x6E90;&#x7684;&#x4F7F;&#x7528;&#x89C4;&#x5219;</p>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#13-&#x7C7B;&#x578B;&#x8F6C;&#x6362;domaintype-transition" class="md-toc-link">
            <p>1.3 &#x7C7B;&#x578B;&#x8F6C;&#x6362;&#xFF08;Domain/Type Transition&#xFF09;</p>

          </a></div>
        </div>
      </details>
    <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#2-hello-seandroid-&#x793A;&#x4F8B;" class="md-toc-link">
            <ol start="2">
<li>Hello SeAndroid &#x793A;&#x4F8B;</li>
</ol>

          </a></div>
        </div>
      </details>
    <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#&#x7B2C;&#x5341;&#x7AE0;-&#x6DFB;&#x52A0;&#x5F00;&#x673A;&#x81EA;&#x542F;&#x52A8;-shell-&#x811A;&#x672C;" class="md-toc-link">
            <p>&#x7B2C;&#x5341;&#x7AE0; &#x6DFB;&#x52A0;&#x5F00;&#x673A;&#x81EA;&#x542F;&#x52A8; Shell &#x811A;&#x672C;</p>

          </a></div><details style="padding:0;;padding-left:24px;" open>
        <summary class="md-toc-link-wrapper">
          <a href="#&#x7B2C;&#x5341;&#x4E00;&#x7AE0;-&#x5982;&#x4F55;&#x9605;&#x8BFB;&#x7CFB;&#x7EDF;&#x6E90;&#x7801;-cc-&#x7BC7;" class="md-toc-link"><p>&#x7B2C;&#x5341;&#x4E00;&#x7AE0; &#x5982;&#x4F55;&#x9605;&#x8BFB;&#x7CFB;&#x7EDF;&#x6E90;&#x7801; C/C++ &#x7BC7;</p>
</a>
          </summary>
        <div>
          <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#1-&#x5DE5;&#x5177;&#x7BC7;" class="md-toc-link">
            <ol>
<li>&#x5DE5;&#x5177;&#x7BC7;</li>
</ol>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#2-&#x624B;&#x6BB5;&#x7BC7;" class="md-toc-link">
            <ol start="2">
<li>&#x624B;&#x6BB5;&#x7BC7;</li>
</ol>

          </a></div>
        </div>
      </details>
    <details style="padding:0;;padding-left:24px;" open>
        <summary class="md-toc-link-wrapper">
          <a href="#&#x7B2C;&#x5341;&#x4E8C;&#x7AE0;-&#x5982;&#x4F55;&#x9605;&#x8BFB;&#x7CFB;&#x7EDF;&#x6E90;&#x7801;-java-&#x7BC7;" class="md-toc-link"><p>&#x7B2C;&#x5341;&#x4E8C;&#x7AE0; &#x5982;&#x4F55;&#x9605;&#x8BFB;&#x7CFB;&#x7EDF;&#x6E90;&#x7801; Java &#x7BC7;</p>
</a>
          </summary>
        <div>
          <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#1-&#x5DE5;&#x5177;&#x7BC7;--aidegen--android-studio" class="md-toc-link">
            <ol>
<li>&#x5DE5;&#x5177;&#x7BC7; &#x2014;&#x2014; AIDEGen + Android Studio</li>
</ol>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#2-&#x624B;&#x6BB5;&#x7BC7;--java-&#x6E90;&#x7801;&#x7684;&#x9605;&#x8BFB;" class="md-toc-link">
            <ol start="2">
<li>&#x624B;&#x6BB5;&#x7BC7; &#x2014;&#x2014; Java &#x6E90;&#x7801;&#x7684;&#x9605;&#x8BFB;</li>
</ol>

          </a></div>
        </div>
      </details>
    
        </div>
      </details>
    
</div>
<h1 class="mume-header" id="%E5%86%99%E7%BB%99%E5%BA%94%E7%94%A8%E5%BC%80%E5%8F%91%E7%9A%84-android-framework-%E6%95%99%E7%A8%8B%E7%8E%A9%E8%BD%AC-aosp-%E7%AF%87">&#x5199;&#x7ED9;&#x5E94;&#x7528;&#x5F00;&#x53D1;&#x7684; Android Framework &#x6559;&#x7A0B;&#x2014;&#x2014;&#x73A9;&#x8F6C; AOSP &#x7BC7;</h1>

<h2 class="mume-header" id="%E7%AC%AC%E4%B8%80%E7%AB%A0-aosp-%E6%9E%81%E9%80%9F%E4%B8%8A%E6%89%8B">&#x7B2C;&#x4E00;&#x7AE0; AOSP &#x6781;&#x901F;&#x4E0A;&#x624B;</h2>

<h3 class="mume-header" id="1-%E7%A1%AC%E4%BB%B6%E8%A6%81%E6%B1%82">1. &#x786C;&#x4EF6;&#x8981;&#x6C42;</h3>

<p>&#x7528;&#x4E8E; Android Framework &#x5F00;&#x53D1;&#x7684;&#x7535;&#x8111;&#x9700;&#x8981;&#x8F83;&#x5F3A;&#x7684; CPU&#xFF0C;&#x5927;&#x5185;&#x5B58;&#xFF0C;&#x5927;&#x5B58;&#x50A8;&#xFF0C;&#x4E00;&#x822C;&#x6765;&#x8BF4;&#x9700;&#x8981;&#x6EE1;&#x8DB3;&#x4EE5;&#x4E0B;&#x8981;&#x6C42;&#xFF1A;</p>
<ul>
<li>CPU &#x4E0D;&#x4F4E;&#x4E8E; 6 &#x6838;&#x5FC3;&#xFF0C;&#x5EFA;&#x8BAE; 8 &#x6838;&#x53CA;&#x4EE5;&#x4E0A;</li>
<li>&#x5185;&#x5B58;&#x4E0D;&#x4F4E;&#x4E8E; 32G&#xFF0C;&#x5EFA;&#x8BAE; 64G</li>
<li>&#x5B58;&#x50A8;&#x7A7A;&#x95F4;&#x4E0D;&#x4F4E;&#x4E8E; 500G&#xFF0C;&#x5EFA;&#x8BAE; 1TB SSD</li>
</ul>
<h3 class="mume-header" id="2-%E8%99%9A%E6%8B%9F%E6%9C%BA%E5%AE%89%E8%A3%85">2. &#x865A;&#x62DF;&#x673A;&#x5B89;&#x88C5;</h3>

<p>&#x8FD9;&#x91CC;&#x63A8;&#x8350;&#x5728; Windows &#x4E0B;&#x4F7F;&#x7528; VMware &#x865A;&#x62DF;&#x673A;&#x8F6F;&#x4EF6;&#x5B89;&#x88C5; Ubuntu20.04 &#x8FDB;&#x884C;&#x5F00;&#x53D1;&#xFF08;AOSP &#x5B98;&#x7F51;&#x63A8;&#x8350;&#x7684;&#x7684;&#x662F; Ubuntu18.04&#xFF0C;&#x4F46; Ubuntu20.04 &#x5728; VMware&#x4E0B;&#x517C;&#x5BB9;&#x6027;&#x66F4;&#x597D;&#xFF0C;&#x5B9E;&#x6D4B;&#x4E5F;&#x6CA1;&#x6709;&#x4EFB;&#x4F55;&#x517C;&#x5BB9;&#x6027;&#x95EE;&#x9898;&#xFF09;&#xFF0C;&#x5B89;&#x88C5;&#x7CFB;&#x7EDF;&#x7684;&#x8FC7;&#x7A0B;&#x5982;&#x4E0B;&#xFF1A;</p>
<p><strong>&#x5728;<a href="https://releases.ubuntu.com/focal/">&#x5B98;&#x7F51;</a>&#x4E0B;&#x8F7D;&#x597D; Ubuntu20.04 &#x684C;&#x9762;&#x7248;&#x7CFB;&#x7EDF;&#x955C;&#x50CF;</strong></p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230220211821.png" alt></p>
<p><strong>VMware &#x65B0;&#x5EFA;&#x865A;&#x62DF;&#x673A;</strong></p>
<p>&#x6253;&#x5F00; VMware&#xFF0C;&#x83DC;&#x5355;&#x680F;&#x9009;&#x62E9; <code>&#x6587;&#x4EF6; -&gt; &#x65B0;&#x5EFA;&#x865A;&#x62DF;&#x673A;</code> &#x540E;&#xFF0C;&#x51FA;&#x73B0;&#x4EE5;&#x4E0B;&#x754C;&#x9762;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230220212516.png" alt></p>
<p>&#x9009;&#x62E9; <code>&#x81EA;&#x5B9A;&#x4E49;&#x9AD8;&#x7EA7;</code>&#xFF0C;&#x7136;&#x540E;&#x70B9;&#x51FB; <code>&#x4E0B;&#x4E00;&#x6B65;</code>&#xFF0C;&#x51FA;&#x73B0;&#x4EE5;&#x4E0B;&#x754C;&#x9762;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230220212614.png" alt></p>
<p>&#x8FD9;&#x91CC;&#x4E0D;&#x7528;&#x6539;&#xFF0C;&#x70B9;&#x51FB; <code>&#x4E0B;&#x4E00;&#x6B65;</code>&#xFF0C;&#x51FA;&#x73B0;&#x4EE5;&#x4E0B;&#x754C;&#x9762;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230220212726.png" alt></p>
<p>&#x9009;&#x62E9; <code>&#x7A0D;&#x5019;&#x5B89;&#x88C5;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;</code>&#xFF0C;&#x70B9;&#x51FB; <code>&#x4E0B;&#x4E00;&#x6B65;</code>&#xFF0C;&#x51FA;&#x73B0;&#x4EE5;&#x4E0B;&#x754C;&#x9762;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230220212836.png" alt></p>
<p>&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x9009;&#x62E9; <code>Linux</code>&#xFF0C;&#x7248;&#x672C;&#x9009;&#x62E9; <code>Ubuntu 64&#x4F4D;</code>&#xFF0C;&#x7136;&#x540E;&#x70B9;&#x51FB; <code>&#x4E0B;&#x4E00;&#x6B65;</code>&#xFF0C;&#x51FA;&#x73B0;&#x4EE5;&#x4E0B;&#x754C;&#x9762;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230220213434.png" alt></p>
<p><code>&#x865A;&#x62DF;&#x673A;&#x540D;&#x79F0;</code>&#x5904;&#x53D6;&#x4E00;&#x4E2A;&#x4F60;&#x559C;&#x6B22;&#x7684;&#x540D;&#x5B57;&#xFF0C;<code>&#x4F4D;&#x7F6E;</code>&#x9009;&#x62E9;&#x5269;&#x4F59;&#x7A7A;&#x95F4;&#x8D85;&#x8FC7; 500G &#x7684;&#x8DEF;&#x5F84;&#xFF0C;&#x7136;&#x540E;&#x70B9;&#x51FB; <code>&#x4E0B;&#x4E00;&#x6B65;</code>&#xFF0C;&#x51FA;&#x73B0;&#x4EE5;&#x4E0B;&#x754C;&#x9762;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230220213715.png" alt></p>
<p><code>&#x5904;&#x7406;&#x5668;&#x6570;&#x91CF;</code>&#x9009;&#x62E9; 1&#xFF0C;<code>&#x6BCF;&#x4E2A;&#x5904;&#x7406;&#x5668;&#x7684;&#x5185;&#x6838;&#x6570;&#x91CF;</code>&#x9009;&#x62E9;&#x4F60; CPU &#x7684;&#x7EBF;&#x7A0B;&#x6570;&#xFF0C;&#x6BD4;&#x5982;&#x6211;&#x7684; CPU &#x662F; amd ryzen 3800x&#xFF0C;8&#x6838;&#x5FC3;16&#x7EBF;&#x7A0B;&#xFF0C;&#x90A3;&#x4E48;&#x9009;&#x62E9; 16,&#x7136;&#x540E;&#x70B9;&#x51FB; <code>&#x4E0B;&#x4E00;&#x6B65;</code>&#xFF0C;&#x51FA;&#x73B0;&#x4EE5;&#x4E0B;&#x754C;&#x9762;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230220213928.png" alt></p>
<p>&#x865A;&#x62DF;&#x673A;&#x5185;&#x5B58;&#x7684;&#x8BBE;&#x7F6E;&#x5EFA;&#x8BAE;&#x5C3D;&#x53EF;&#x80FD;&#x7684;&#x5927;&#x4E00;&#x4E9B;&#xFF0C;&#x5185;&#x5B58;&#x5C0F;&#x4E86;&#xFF0C;&#x5168;&#x7F16;&#x8BD1;&#x7CFB;&#x7EDF;&#x4F1A;&#x51FA;&#x9519;&#xFF0C;&#x8FD9;&#x91CC;&#x9009;&#x62E9; 32G&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230220214329.png" alt></p>
<p>&#x7F51;&#x7EDC;&#x7C7B;&#x578B;&#x9009;&#x62E9; <code>&#x4F7F;&#x7528;&#x6865;&#x63A5;&#x7F51;&#x7EDC;</code>&#xFF0C;&#x7136;&#x540E;&#x70B9;&#x51FB; <code>&#x4E0B;&#x4E00;&#x6B65;</code>&#xFF0C;&#x51FA;&#x73B0;&#x4EE5;&#x4E0B;&#x754C;&#x9762;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230220214415.png" alt></p>
<p>&#x8FD9;&#x91CC;&#x4E0D;&#x6539;&#x52A8;&#xFF0C;&#x76F4;&#x63A5;&#x70B9;&#x51FB;&#x4E0B;&#x4E00;&#x6B65;&#xFF0C;&#x51FA;&#x73B0;&#x4EE5;&#x4E0B;&#x754C;&#x9762;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230220214521.png" alt></p>
<p>&#x8FD9;&#x91CC;&#x4E0D;&#x6539;&#x52A8;&#xFF0C;&#x76F4;&#x63A5;&#x70B9;&#x51FB; <code>&#x4E0B;&#x4E00;&#x6B65;</code>&#xFF0C;&#x51FA;&#x73B0;&#x4EE5;&#x4E0B;&#x754C;&#x9762;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230220214715.png" alt></p>
<p>&#x8FD9;&#x91CC;&#x4E0D;&#x6539;&#x52A8;&#xFF0C;&#x76F4;&#x63A5;&#x70B9;&#x51FB; <code>&#x4E0B;&#x4E00;&#x6B65;</code>&#xFF0C;&#x51FA;&#x73B0;&#x4EE5;&#x4E0B;&#x754C;&#x9762;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230220214944.png" alt></p>
<p>&#x6839;&#x636E;&#x4F60;&#x78C1;&#x76D8;&#x7684;&#x7A7A;&#x95F4;&#xFF0C;<code>&#x6700;&#x5927;&#x78C1;&#x76D8;&#x5927;&#x5C0F;</code>&#x5C3D;&#x53EF;&#x80FD;&#x8BBE;&#x7F6E;&#x5927;&#x4E00;&#x70B9;&#xFF0C;&#x6211;&#x8FD9;&#x91CC;&#x8BBE;&#x7F6E;&#x4E3A; 1024 G&#xFF0C;&#x7136;&#x540E;&#x70B9;&#x51FB; <code>&#x4E0B;&#x4E00;&#x6B65;</code>&#xFF0C;&#x51FA;&#x73B0;&#x4EE5;&#x4E0B;&#x754C;&#x9762;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230220215050.png" alt></p>
<p>&#x8FD9;&#x91CC;&#x4E0D;&#x6539;&#x52A8;&#xFF0C;&#x76F4;&#x63A5;&#x70B9;&#x51FB; <code>&#x4E0B;&#x4E00;&#x6B65;</code>&#xFF0C;&#x51FA;&#x73B0;&#x4EE5;&#x4E0B;&#x754C;&#x9762;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230220215149.png" alt></p>
<p>&#x9009;&#x62E9; <code>&#x81EA;&#x5B9A;&#x4E49;&#x786C;&#x4EF6;</code>&#xFF0C;&#x51FA;&#x73B0;&#x4EE5;&#x4E0B;&#x754C;&#x9762;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230220215550.png" alt></p>
<p>&#x9009;&#x62E9; <code>&#x65B0; CD/DVD(SATA)</code>&#xFF0C;&#x51FA;&#x73B0;&#x4EE5;&#x4E0B;&#x754C;&#x9762;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230220215722.png" alt></p>
<p>&#x53F3;&#x4FA7;&#x9009;&#x62E9; <code>&#x4F7F;&#x7528; ISO &#x6620;&#x50CF;&#x6587;&#x4EF6;</code>&#xFF0C;&#x70B9;&#x51FB;&#x6D4F;&#x89C8;&#xFF0C;&#x9009;&#x62E9;&#x6211;&#x4EEC;&#x521A;&#x624D;&#x4E0B;&#x8F7D;&#x597D;&#x7684;&#x7CFB;&#x7EDF;&#x955C;&#x50CF;&#xFF0C;&#x7136;&#x540E;&#x70B9;&#x51FB; <code>&#x5173;&#x95ED;</code>&#xFF0C;&#x51FA;&#x73B0;&#x4EE5;&#x4E0B;&#x754C;&#x9762;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230220215919.png" alt></p>
<p>&#x7136;&#x540E;&#x70B9;&#x51FB;&#x5B8C;&#x6210;&#xFF0C;&#x81F3;&#x6B64;&#xFF0C;&#x865A;&#x62DF;&#x673A;&#x65B0;&#x5EFA;&#x5B8C;&#x6BD5;&#x3002;</p>
<p><strong>&#x7CFB;&#x7EDF;&#x5B89;&#x88C5;</strong></p>
<p>&#x6253;&#x5F00; VMware &#x865A;&#x62DF;&#x673A;&#x8F6F;&#x4EF6;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230220220138.png" alt></p>
<p>&#x70B9;&#x51FB;&#x5DE6;&#x4FA7; <code>Ubuntu 64&#x4F4D;</code> &#x5373;&#x6211;&#x4EEC;&#x521A;&#x624D;&#x65B0;&#x5EFA;&#x7684;&#x865A;&#x62DF;&#x673A;&#xFF0C;&#x70B9;&#x51FB;&#x53F3;&#x4FA7; <code>&#x5F00;&#x542F;&#x6B64;&#x865A;&#x62DF;&#x673A;</code>&#xFF0C;&#x7136;&#x540E;&#x5C31;&#x8FDB;&#x5165;&#x4E86; Ubuntu &#x7684;&#x7CFB;&#x7EDF;&#x5B89;&#x88C5;&#x6D41;&#x7A0B;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230220224245.png" alt></p>
<p>&#x5DE6;&#x4FA7;&#x9009;&#x62E9; <code>English</code>&#xFF0C;&#x53F3;&#x4FA7;&#x70B9;&#x51FB; <code>install Ubuntu</code>&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230220224849.png" alt></p>
<p>&#x70B9;&#x51FB; <code>continue</code>&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230220225027.png" alt></p>
<p>&#x70B9;&#x51FB; <code>continue</code>&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230220225244.png" alt></p>
<p>&#x70B9;&#x51FB; <code>install now</code>&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230220225737.png" alt></p>
<p>&#x70B9;&#x51FB; <code>continue</code>&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230220225838.png" alt></p>
<p>&#x70B9;&#x51FB;&#x4EE5;&#x540E;&#x4F1A;&#x663E;&#x793A;&#x4E00;&#x5F20;&#x5730;&#x56FE;&#xFF0C;&#x8FD9;&#x91CC;&#x5C31;&#x4E0D;&#x8D34;&#x56FE;&#x4E86;&#xFF08;&#x6709;&#x5730;&#x56FE;&#x5BA1;&#x6838;&#x4E0D;&#x8FC7;&#xFF09;&#xFF0C;&#x5C31;&#x662F;&#x4E00;&#x5F20;&#x5730;&#x56FE;&#xFF0C;&#x70B9;&#x51FB;&#x4E00;&#x4E0B;&#x4E2D;&#x56FD;&#x5373;&#x53EF;&#x3002;</p>
<p>&#x7136;&#x540E;&#x70B9;&#x4E00;&#x4E0B;&#x4E2D;&#x56FD;&#x5730;&#x56FE;&#xFF0C;&#x4E0B;&#x9762;&#x663E;&#x793A; <code>Shanghai</code>&#xFF0C;&#x70B9;&#x51FB; <code>continue</code>&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230220225949.png" alt></p>
<p>&#x4F9D;&#x6B21;&#x8F93;&#x5165;&#xFF1A;</p>
<ul>
<li>&#x540D;&#x5B57;</li>
<li>&#x7535;&#x8111;&#x540D;&#x5B57;</li>
<li>&#x7528;&#x6237;&#x540D;</li>
<li>&#x5BC6;&#x7801;</li>
</ul>
<p>&#x7136;&#x540E;&#x70B9;&#x51FB; <code>continue</code>&#xFF0C;&#x7136;&#x540E;&#x7B49;&#x5F85;&#x5B89;&#x88C5;&#x5B8C;&#x6210;&#xFF0C;&#x91CD;&#x542F;&#x865A;&#x62DF;&#x673A;&#x5373;&#x53EF;&#x3002;</p>
<p>&#x7CFB;&#x7EDF;&#x5B89;&#x88C5;&#x5B8C;&#x6210;&#x540E;&#xFF0C;&#x5173;&#x95ED;&#x865A;&#x62DF;&#x673A;&#xFF0C;&#x70B9;&#x51FB; <code>&#x7F16;&#x8F91;&#x865A;&#x62DF;&#x673A;&#x8BBE;&#x7F6E;</code>&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230322121536.png" alt></p>
<p>&#x9009;&#x62E9;<code>&#x5904;&#x7406;&#x5668;</code>&#xFF0C;&#x5E76;&#x52FE;&#x9009;&#x4E0A;&#x865A;&#x62DF;&#x5316;&#x5F15;&#x64CE;&#x4E24;&#x4E2A;&#x9009;&#x9879;&#xFF08;&#x5982;&#x679C;&#x662F; intel &#x5904;&#x7406;&#x5668;&#x52FE;&#x9009;&#x7B2C;&#x4E00;&#x4E2A;&#x5373;&#x53EF;&#xFF09;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230322121711.png" alt></p>
<h3 class="mume-header" id="3-%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA">3. &#x5F00;&#x53D1;&#x73AF;&#x5883;&#x642D;&#x5EFA;</h3>

<p>&#x5B89;&#x88C5;&#x597D;&#x7CFB;&#x7EDF;&#x540E;&#x9700;&#x8981;&#x5B89;&#x88C5;&#x5FC5;&#x8981;&#x7684;&#x8F6F;&#x4EF6;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token function">sudo</span> <span class="token function">apt-get</span> <span class="token function">install</span> git-core gnupg flex bison build-essential <span class="token function">zip</span> <span class="token function">curl</span> zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 libncurses5 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc <span class="token function">unzip</span> fontconfig python
</pre><p>&#x81F3;&#x6B64;&#xFF0C;&#x5F00;&#x53D1;&#x73AF;&#x5883;&#x5C31;&#x642D;&#x5EFA;&#x597D;&#x4E86;&#x3002;</p>
<h3 class="mume-header" id="4-%E4%B8%8B%E8%BD%BD%E7%BC%96%E8%AF%91%E6%BA%90%E7%A0%81">4. &#x4E0B;&#x8F7D;&#x7F16;&#x8BD1;&#x6E90;&#x7801;</h3>

<h4 class="mume-header" id="41-%E4%B8%8B%E8%BD%BD-repo-%E5%B7%A5%E5%85%B7">4.1 &#x4E0B;&#x8F7D; repo &#x5DE5;&#x5177;</h4>

<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token function">mkdir</span> ~/bin
<span class="token function">curl</span> https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o ~/bin/repo
<span class="token function">chmod</span> +x ~/bin/repo
</pre><p>repo &#x7684;&#x8FD0;&#x884C;&#x8FC7;&#x7A0B;&#x4E2D;&#x4F1A;&#x5C1D;&#x8BD5;&#x8BBF;&#x95EE;&#x5B98;&#x65B9;&#x7684; git &#x6E90;&#x66F4;&#x65B0;&#x81EA;&#x5DF1;&#xFF0C;&#x5982;&#x679C;&#x60F3;&#x4F7F;&#x7528; tuna &#x7684;&#x955C;&#x50CF;&#x6E90;&#x8FDB;&#x884C;&#x66F4;&#x65B0;&#xFF0C;&#x53EF;&#x4EE5;&#x5C06;&#x5982;&#x4E0B;&#x5185;&#x5BB9;&#x590D;&#x5236;&#x5230;&#x4F60;&#x7684; ~/.bashrc &#x6216;&#x8005; ~/.zshrc &#x91CC;&#x3002;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token builtin class-name">export</span> <span class="token assign-left variable">REPO_URL</span><span class="token operator">=</span><span class="token string">&apos;https://mirrors.tuna.tsinghua.edu.cn/git/git-repo&apos;</span>
<span class="token assign-left variable"><span class="token environment constant">PATH</span></span><span class="token operator">=~</span>/bin:<span class="token environment constant">$PATH</span>
</pre><p>&#x7136;&#x540E; source &#x4E00;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token builtin class-name">source</span> ~/.bashrc
<span class="token comment">#&#x5982;&#x679C;&#x4F7F;&#x7528;&#x7684;&#x662F; zsh</span>
<span class="token comment">#source ~/.zshrc</span>
</pre><h4 class="mume-header" id="42-%E5%88%9D%E5%A7%8B%E5%8C%96%E4%BB%93%E5%BA%93%E5%B9%B6%E5%90%8C%E6%AD%A5%E8%BF%9C%E7%A8%8B%E4%BB%A3%E7%A0%81">4.2 &#x521D;&#x59CB;&#x5316;&#x4ED3;&#x5E93;&#x5E76;&#x540C;&#x6B65;&#x8FDC;&#x7A0B;&#x4EE3;&#x7801;</h4>

<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token function">git</span> config --global user.email <span class="token string">&quot;you@example.com&quot;</span>
<span class="token function">git</span> config --global user.name <span class="token string">&quot;Your Name&quot;</span>
<span class="token function">mkdir</span> aosp 
<span class="token builtin class-name">cd</span> asop
<span class="token comment">#&#x521D;&#x59CB;&#x5316;&#x4ED3;&#x5E93;,-b &#x6307;&#x793A;&#x5206;&#x652F;&#xFF0C;&#x8FD9;&#x91CC;&#x4F7F;&#x7528; android10</span>
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-10.0.0_r41
<span class="token comment">#&#x540C;&#x6B65;&#x8FDC;&#x7A0B;&#x4EE3;&#x7801;</span>
repo <span class="token function">sync</span>
</pre><p>-b &#x540E;&#x9762;&#x7684;&#x503C;&#x53C2;&#x8003;<a href="https://source.android.com/docs/setup/start/build-numbers?hl=zh-cn#source-code-tags-and-builds">&#x6E90;&#x4EE3;&#x7801;&#x6807;&#x8BB0;&#x548C; build</a>&#x3002;&#x8FD9;&#x91CC;&#x9009;&#x7528;&#x4E86; android-10.0.0_r41 &#x7248;&#x672C;&#x7528;&#x4E8E;&#x5B66;&#x4E60;&#x3002;Android &#x6BCF;&#x5E74;&#x90FD;&#x4F1A;&#x66F4;&#x65B0;&#x4E00;&#x4E2A;&#x5927;&#x7248;&#x672C;&#xFF0C;&#x5B66;&#x4E60;&#x7684;&#x89D2;&#x5EA6;&#x6765;&#x8BF4;&#xFF0C;&#x9009;&#x62E9;&#x4E00;&#x4E2A;&#x4E0D;&#x592A;&#x8001;&#x7684;&#x7248;&#x672C;&#x5373;&#x53EF;&#xFF0C;&#x4E0D;&#x5FC5;&#x8FFD;&#x65B0;&#x3002;</p>
<h4 class="mume-header" id="43-%E7%BC%96%E8%AF%91%E6%BA%90%E7%A0%81">4.3 &#x7F16;&#x8BD1;&#x6E90;&#x7801;</h4>

<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token builtin class-name">source</span> build/envsetup.sh
lunch aosp_x86_64-eng
<span class="token function">make</span> -j16
</pre><h4 class="mume-header" id="44-%E8%BF%90%E8%A1%8C%E6%A8%A1%E6%8B%9F%E5%99%A8">4.4 &#x8FD0;&#x884C;&#x6A21;&#x62DF;&#x5668;</h4>

<pre data-role="codeBlock" data-info="bash" class="language-bash">emulator -verbose -cores <span class="token number">4</span> -show-kernel
</pre><p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230220231917.png" alt></p>
<h3 class="mume-header" id="5-%E4%BB%8E%E4%B8%80%E4%B8%AA%E7%AE%80%E5%8D%95%E7%9A%84%E5%AE%9E%E9%99%85%E5%BC%80%E5%8F%91%E9%9C%80%E6%B1%82%E4%BD%93%E9%AA%8C-framework-%E5%BC%80%E5%8F%91">5. &#x4ECE;&#x4E00;&#x4E2A;&#x7B80;&#x5355;&#x7684;&#x5B9E;&#x9645;&#x5F00;&#x53D1;&#x9700;&#x6C42;&#x4F53;&#x9A8C; Framework &#x5F00;&#x53D1;</h3>

<p>&#x9700;&#x6C42;&#xFF1A;&#x53BB;&#x6389;&#x539F;&#x751F; Launcher &#x4E2D;&#x7684; google &#x641C;&#x7D22;&#x680F;&#x3002;</p>
<p>&#x5F88;&#x591A;&#x4EA7;&#x54C1;&#xFF0C;&#x6BD4;&#x5982;&#x7528;&#x4E8E;&#x4ED3;&#x5E93;&#xFF0C;&#x7535;&#x5546;&#xFF0C;&#x7269;&#x6D41;&#x7684; pda &#x7B49;&#xFF0C;&#x66F4;&#x591A;&#x7684;&#x662F;&#x8003;&#x8651;&#x529F;&#x80FD;&#x6027;&#x548C;&#x7A33;&#x5B9A;&#x6027;&#xFF0C;UI &#x7684;&#x7F8E;&#x89C2;&#x548C;&#x6613;&#x7528;&#x6027;&#x662F;&#x5176;&#x6B21;&#x7684;&#x3002;&#x8FD9;&#x4E9B;&#x4EA7;&#x54C1;&#x4E00;&#x822C;&#x662F;&#x4E0D;&#x4F1A;&#x91CD;&#x65B0;&#x5F00;&#x53D1;&#x548C;&#x5B9A;&#x5236; Launcher &#x7684;&#xFF0C;&#x4F46;&#x662F;&#x4F1A;&#x5BF9; Launcher &#x505A;&#x4E00;&#x4E9B;&#x4FEE;&#x6539;&#xFF0C;&#x6BD4;&#x5982;&#x4E00;&#x4E2A;&#x5E38;&#x89C1;&#x7684;&#x9700;&#x6C42;&#x662F;&#xFF1A;<strong>&#x53BB;&#x6389;&#x539F;&#x751F; Launcher &#x4E2D;&#x7684; google &#x641C;&#x7D22;&#x680F;</strong>&#x3002;</p>
<p>&#x7531;&#x4E8E;&#x4F17;&#x6240;&#x5468;&#x77E5;&#x7684;&#x539F;&#x56E0; google &#x641C;&#x7D22;&#x680F;&#x5728;&#x4E2D;&#x56FD;&#x662F;&#x6CA1;&#x6709;&#x529E;&#x6CD5;&#x4F7F;&#x7528;&#x7684;&#x3002;&#x5728;&#x4E2D;&#x56FD;&#x9500;&#x552E;&#x7684;&#x4EA7;&#x54C1;&#xFF0C;&#x80AF;&#x5B9A;&#x662F;&#x8981;&#x628A;&#x5B83;&#x53BB;&#x6389;&#x7684;&#x3002;</p>
<p>&#x7B2C;&#x4E00;&#x6B65;&#xFF1A;&#x4FEE;&#x6539;&#x6587;&#x4EF6; <code>packages/apps/Launcher3/res/layout/search_container_workspace.xml</code>&#xFF0C;&#x5C06;&#x4EE5;&#x4E0B;&#x5185;&#x5BB9;&#x6CE8;&#x91CA;&#x6389;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="xml" class="language-xml">    <span class="token comment">&lt;!-- &lt;fragment
        android:name=&quot;com.android.launcher3.qsb.QsbContainerView$QsbFragment&quot;
        android:layout_width=&quot;match_parent&quot;
        android:tag=&quot;qsb_view&quot;
        android:layout_height=&quot;match_parent&quot;/&gt; --&gt;</span>
</pre><p>&#x7B2C;&#x4E8C;&#x6B65;&#xFF1A;&#x4FEE;&#x6539;&#x6587;&#x4EF6;&#xFF1A;<code>packages/apps/Launcher3/src/com/android/launcher3/Workspace.java</code> &#x5C06;&#x4EE5;&#x4E0B;&#x5185;&#x5BB9;&#x6CE8;&#x91CA;&#x6389;</p>
<pre data-role="codeBlock" data-info="java" class="language-java">        <span class="token comment">// CellLayout.LayoutParams lp = new CellLayout.LayoutParams(0, 0, firstPage.getCountX(), 1);</span>
        <span class="token comment">// lp.canReorder = false;</span>
        <span class="token comment">// if (!firstPage.addViewToCellLayout(qsb, 0, R.id.search_container_workspace, lp, true)) {</span>
        <span class="token comment">//     Log.e(TAG, &quot;Failed to add to item at (0, 0) to CellLayout&quot;);</span>
        <span class="token comment">// }</span>
</pre><p>&#x7B2C;&#x4E09;&#x6B65;&#xFF1A;&#x91CD;&#x65B0;&#x7F16;&#x8BD1;&#x6E90;&#x7801;&#xFF0C;&#x542F;&#x52A8;&#x6A21;&#x62DF;&#x5668;</p>
<pre data-role="codeBlock" data-info class="language-"><code>make -j16
emulator
</code></pre><p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230221095253.png" alt></p>
<p>&#x53EF;&#x4EE5;&#x770B;&#x5230; Google &#x641C;&#x7D22;&#x6846;&#x6CA1;&#x6709;&#x4E86;&#x3002;</p>
<p>&#x5F88;&#x591A;&#x540C;&#x5B66;&#x53EF;&#x80FD;&#x6709;&#x7591;&#x95EE;&#xFF0C;&#x4F60;&#x600E;&#x4E48;&#x77E5;&#x9053;&#x8FD9;&#x4E48;&#x6539;&#x5C31;&#x53EF;&#x4EE5;&#x4E86;&#xFF1F;&#x5176;&#x5B9E;&#x529E;&#x6CD5;&#x5C31;&#x4E00;&#x4E2A;&#x2014;&#x2014;<strong>&#x8BFB;&#x6E90;&#x7801;</strong>&#x3002;Launcher &#x4E5F;&#x662F;&#x4E00;&#x4E2A; Android &#x5E94;&#x7528;&#xFF0C;&#x548C;&#x6211;&#x4EEC;&#x5E73;&#x65F6;&#x5F00;&#x53D1;&#x7684; App &#x6CA1;&#x6709;&#x672C;&#x8D28;&#x7684;&#x533A;&#x522B;&#x3002;&#x5C31;&#x50CF;&#x6211;&#x4EEC;&#x63A5;&#x624B;&#x522B;&#x4EBA;&#x5F00;&#x53D1;&#x7684;&#x9879;&#x76EE;&#xFF0C;&#x53BB;&#x89E3;&#x51B3;&#x9879;&#x76EE;&#x4E2D;&#x7684; bug&#xFF0C;&#x6DFB;&#x52A0;&#x65B0;&#x7684;&#x9700;&#x6C42;&#x662F;&#x4E00;&#x6837;&#x7684;&#x3002;</p>
<p>Android Framework &#x4E0D;&#x540C;&#x7684;&#x662F;&#xFF0C;&#x4EE3;&#x7801;&#x91CF;&#x5927;&#xFF0C;&#x6D89;&#x53CA;&#x77E5;&#x8BC6;&#x5E7F;&#x6CDB;&#xFF0C;App &#x5F00;&#x53D1;&#x540C;&#x5B66;&#x5982;&#x679C;&#x6CA1;&#x6709;&#x4EBA;&#x6307;&#x5BFC;&#xFF0C;&#x9605;&#x8BFB;&#x8D77;&#x6765;&#x6BD4;&#x8F83;&#x5403;&#x529B;&#x3002;&#x540E;&#x7EED;&#x5185;&#x5BB9;&#x6211;&#x4EEC;&#x5E26;&#x7740;&#x5927;&#x5BB6;&#x7531;&#x6D45;&#x5165;&#x6DF1;&#xFF0C;&#x6B65;&#x6B65;&#x5206;&#x89E3;&#xFF0C;&#x4E3A; App &#x5F00;&#x53D1;&#x7684;&#x540C;&#x5B66;&#x89E3;&#x5F00; Android Framework &#x7684;&#x795E;&#x79D8;&#x9762;&#x7EB1;&#x3002;</p>
<h3 class="mume-header" id="6-%E6%80%BB%E7%BB%93">6. &#x603B;&#x7ED3;</h3>

<p>&#x672C;&#x6587;&#x4E3B;&#x8981;&#x4ECB;&#x7ECD;&#x4E86;&#x4EE5;&#x4E0B;&#x51E0;&#x4E2A;&#x65B9;&#x9762;&#x7684;&#x5185;&#x5BB9;&#xFF1A;</p>
<ul>
<li>&#x865A;&#x62DF;&#x673A;&#x5B89;&#x88C5;</li>
<li>&#x5F00;&#x53D1;&#x73AF;&#x5883;&#x642D;&#x5EFA;</li>
<li>&#x4E0B;&#x8F7D;&#x7F16;&#x8BD1;&#x6E90;&#x7801;</li>
<li>&#x4ECE;&#x4E00;&#x4E2A;&#x7B80;&#x5355;&#x7684;&#x5B9E;&#x9645;&#x5F00;&#x53D1;&#x9700;&#x6C42;&#x4F53;&#x9A8C; Framework &#x5F00;&#x53D1;</li>
</ul>
<p>&#x57FA;&#x672C;&#x662F;&#x504F;&#x5411;&#x5B9E;&#x9645;&#x64CD;&#x4F5C;&#x7684;&#x5185;&#x5BB9;&#xFF0C;&#x611F;&#x5174;&#x8DA3;&#x7684;&#x540C;&#x5B66;&#x53EF;&#x4EE5;&#x6309;&#x7167;&#x4E0A;&#x9762;&#x4ECB;&#x7ECD;&#x7684;&#x6B65;&#x9AA4;&#x4F53;&#x9A8C;&#x4E00;&#x756A;</p>
<h2 class="mume-header" id="%E7%AC%AC%E4%BA%8C%E7%AB%A0-%E7%B3%BB%E7%BB%9F%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7%E6%8E%A8%E8%8D%90">&#x7B2C;&#x4E8C;&#x7AE0; &#x7CFB;&#x7EDF;&#x5F00;&#x53D1;&#x5DE5;&#x5177;&#x63A8;&#x8350;</h2>

<h3 class="mume-header" id="1-ssh-%E6%9C%8D%E5%8A%A1%E4%B8%8E-tabby-terminal">1. SSH &#x670D;&#x52A1;&#x4E0E; Tabby Terminal</h3>

<p>SSH &#x670D;&#x52A1;&#x4F7F;&#x5F97;&#x6211;&#x4EEC;&#x5728;&#x5176;&#x4ED6;&#x5E73;&#x53F0;&#x4E0A;&#x901A;&#x8FC7; SSH &#x5BA2;&#x6237;&#x7AEF;&#x7A0B;&#x5E8F;&#x5373;&#x53EF;&#x8BBF;&#x95EE;&#x5230;&#x6211;&#x4EEC;&#x7684; linux &#x670D;&#x52A1;&#x5668;&#x3002;&#x65B9;&#x4FBF;&#x6211;&#x4EEC;&#x7684;&#x5F00;&#x53D1;&#x5DE5;&#x4F5C;&#x3002;</p>
<p>&#x63A5;&#x4E0B;&#x6765;&#x6211;&#x4EEC;&#x5206;&#x4E3A;&#x4E24;&#x6B65;&#x6765;&#x4ECB;&#x7ECD; ssh &#x670D;&#x52A1;&#x7684;&#x642D;&#x5EFA;&#x4EE5;&#x53CA;&#x5BA2;&#x6237;&#x7AEF;&#x7684;&#x4F7F;&#x7528;&#xFF1A;</p>
<h4 class="mume-header" id="11-%E9%85%8D%E7%BD%AE-ubuntu-ssh-%E6%9C%8D%E5%8A%A1">1.1 &#x914D;&#x7F6E; Ubuntu ssh &#x670D;&#x52A1;</h4>

<p><strong>&#x5B89;&#x88C5; openssh-server</strong></p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token function">sudo</span> <span class="token function">apt</span> <span class="token function">install</span> openssh-server
<span class="token comment"># &#x5F00;&#x673A;&#x81EA;&#x542F;&#x52A8;</span>
<span class="token function">sudo</span> systemctl <span class="token builtin class-name">enable</span> <span class="token function">ssh</span>
<span class="token comment"># &#x91CD;&#x542F; ssh &#x670D;&#x52A1;</span>
<span class="token function">sudo</span> systemctl restart <span class="token function">ssh</span>
</pre><p><strong>&#x914D;&#x7F6E;&#x56FA;&#x5B9A; IP &#x5730;&#x5740;</strong></p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token function">sudo</span> <span class="token function">apt</span> <span class="token function">install</span> net-tools -y  
<span class="token builtin class-name">cd</span> /etc/netplan
<span class="token comment"># &#x5907;&#x4EFD;&#x65E7;&#x7684;&#x914D;&#x7F6E;&#x6587;&#x4EF6;</span>
<span class="token function">sudo</span> <span class="token function">cp</span> 00-installer-config.yaml  00-installer-config.yaml_before
</pre><pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token comment"># &#x4FEE;&#x6539;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#xFF1A;</span>
<span class="token function">sudo</span> <span class="token function">vim</span> 00-installer-config.yaml

network:
  version: <span class="token number">2</span>
  renderer: NetworkManager
  ethernets:
    enp0s5:   <span class="token comment"># &#x7F51;&#x5361;&#x540D;&#x79F0;</span>
      dhcp4: no     <span class="token comment"># &#x5173;&#x95ED;dhcp</span>
      dhcp6: no
      addresses: <span class="token punctuation">[</span><span class="token number">10.0</span>.0.89/24<span class="token punctuation">]</span>  <span class="token comment"># &#x9759;&#x6001;ip&#xFF0C;&#x6839;&#x636E;&#x81EA;&#x5DF1;&#x7F51;&#x7EDC;&#x60C5;&#x51B5;&#x914D;&#x7F6E;</span>
      gateway4: <span class="token number">10.0</span>.0.1     <span class="token comment"># &#x7F51;&#x5173;&#xFF0C;&#x6839;&#x636E;&#x81EA;&#x5DF1;&#x7F51;&#x7EDC;&#x60C5;&#x51B5;&#x914D;&#x7F6E;</span>
      nameservers:
        addresses: <span class="token punctuation">[</span><span class="token number">10.0</span>.0.1, <span class="token number">114.114</span>.114.114<span class="token punctuation">]</span> <span class="token comment">#dns&#xFF0C;&#x6839;&#x636E;&#x81EA;&#x5DF1;&#x7F51;&#x7EDC;&#x60C5;&#x51B5;&#x914D;&#x7F6E;</span>
</pre><p>&#x4F7F;&#x914D;&#x7F6E;&#x751F;&#x6548;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token function">sudo</span> netplan apply
</pre><p>&#x81F3;&#x6B64;&#xFF0C;&#x56FA;&#x5B9A; IP &#x5C31;&#x914D;&#x7F6E;&#x597D;&#x4E86;&#x3002;</p>
<h4 class="mume-header" id="12-ssh-%E5%AE%A2%E6%88%B7%E7%AB%AF-tabby-terminal">1.2 ssh &#x5BA2;&#x6237;&#x7AEF; Tabby Terminal</h4>

<p>Tabby &#x662F;&#x4E00;&#x6B3E;&#x9AD8;&#x989C;&#x503C;&#xFF0C;&#x5F00;&#x6E90;&#xFF0C;&#x514D;&#x8D39;&#xFF0C;&#x591A;&#x5E73;&#x53F0;&#x7684;&#x547D;&#x4EE4;&#x884C;&#x5DE5;&#x5177;&#xFF0C;ssh &#x5BA2;&#x6237;&#x7AEF;&#x662F;&#x5B83;&#x7684;&#x529F;&#x80FD;&#x4E4B;&#x4E00;&#x3002;</p>
<p>&#x6211;&#x4EEC;&#x5728; <a href="https://tabby.sh/">Tabby&#x5B98;&#x7F51;</a> &#x4E0B;&#x8F7D;&#x5B89;&#x88C5;&#x597D;&#x540E;&#xFF0C;&#x914D;&#x7F6E;&#x597D; ssh &#x8FDE;&#x63A5;&#x914D;&#x7F6E;&#x4FE1;&#x606F;&#x5373;&#x53EF;&#x4F7F;&#x7528; ssh &#x670D;&#x52A1;&#x3002;</p>
<p>&#x914D;&#x7F6E;&#x7684;&#x8FC7;&#x7A0B;&#x5982;&#x4E0B;&#xFF1A;</p>
<ol>
<li>
<p>&#x70B9;&#x51FB;&#x914D;&#x7F6E;<br>
<img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230330183830.png" alt></p>
</li>
<li>
<p>&#x70B9;&#x51FB;&#x914D;&#x7F6E;&#x4E0E;&#x8FDE;&#x63A5;<br>
<img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230330183955.png" alt></p>
</li>
<li>
<p>&#x70B9;&#x51FB;&#x65B0;&#x914D;&#x7F6E;<br>
<img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230330190200.png" alt></p>
</li>
<li>
<p>&#x4E0B;&#x6ED1;&#x83DC;&#x5355;&#xFF0C;&#x9009;&#x62E9; <code>SSH &#x8FDE;&#x63A5;</code><br>
<img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230330190312.png" alt></p>
</li>
<li>
<p>&#x8F93;&#x5165; ssh &#x670D;&#x52A1;&#x4FE1;&#x606F;</p>
<ul>
<li>&#x540D;&#x79F0;&#xFF0C;&#x968F;&#x610F;</li>
<li>&#x4E3B;&#x673A;&#x586B;&#x5199; linux &#x7684;&#x56FA;&#x5B9A; IP &#x5730;&#x5740;&#xFF0C;&#x7AEF;&#x53E3; 22</li>
<li>&#x7528;&#x6237;&#x540D;&#x586B;&#x5199;&#x5B9E;&#x9645;&#x7528;&#x6237;&#x540D;</li>
<li>&#x70B9;&#x51FB;&#x8BBE;&#x7F6E;&#x5BC6;&#x7801;&#xFF0C;&#x6DFB;&#x52A0;&#x7528;&#x6237;&#x540D;&#x5BF9;&#x5E94;&#x7684;&#x5BC6;&#x7801;</li>
<li>&#x70B9;&#x51FB;&#x4FDD;&#x5B58;</li>
</ul>
</li>
</ol>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230330190602.png" alt></p>
<ol start="6">
<li>
<p>&#x9F20;&#x6807;&#x79FB;&#x52A8;&#x81F3; UbuntuForAndroid &#x9009;&#x9879;&#xFF0C;&#x70B9;&#x51FB;&#x4E09;&#x89D2;&#x5F62;<br>
<img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230330191231.png" alt></p>
</li>
<li>
<p>&#x8FDB;&#x5165;&#x8FDC;&#x7A0B; ssh &#x7EC8;&#x7AEF;&#x754C;&#x9762;<br>
<img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230330191401.png" alt></p>
</li>
</ol>
<p>&#x81F3;&#x6B64;&#xFF0C;&#x6211;&#x4EEC;&#x5C31;&#x53EF;&#x4EE5;&#x8FDC;&#x7A0B;&#x7BA1;&#x7406;&#x6211;&#x4EEC;&#x7684; linux &#x4E86;&#x3002;</p>
<h3 class="mume-header" id="2-vim">2. vim</h3>

<p>vim &#x4E3B;&#x8981;&#x7528;&#x4E8E;&#x6587;&#x4EF6;&#x7684;&#x7B80;&#x5355;&#x4FEE;&#x6539;&#xFF0C;&#x9700;&#x8981;&#x638C;&#x63E1;&#xFF1A;</p>
<ul>
<li>&#x6587;&#x4EF6;&#x7684;&#x7B80;&#x5355;&#x4FEE;&#x6539;</li>
<li>&#x6587;&#x4EF6;&#x5185;&#x5BB9;&#x641C;&#x7D22;</li>
</ul>
<p><strong>&#x4E00;&#x822C;&#x6A21;&#x5F0F;</strong></p>
<p>&#x901A;&#x8FC7; <code>vim + &#x6587;&#x4EF6;&#x540D;</code>&#xFF0C;&#x8FDB;&#x5165; vim &#x73AF;&#x5883;&#xFF08;test.txt &#x53EF;&#x4EE5;&#x662F;&#x5F53;&#x524D;&#x76EE;&#x5F55;&#x5DF2;&#x5B58;&#x5728;&#x7684;&#x6587;&#x4EF6;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x662F;&#x5F53;&#x524D;&#x76EE;&#x5F55;&#x4E0D;&#x5B58;&#x5728;&#x7684;&#x6587;&#x4EF6;&#x3002;&#xFF09;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token function">vim</span> test.txt
</pre><p>&#x6B64;&#x65F6;&#xFF0C;&#x6211;&#x4EEC;&#x5728; vim &#x7684;&#x4E00;&#x822C;&#x6A21;&#x5F0F;&#x4E0B;&#xFF0C;&#x5982;&#x679C; test.txt &#x6587;&#x4EF6;&#x6709;&#x5185;&#x5BB9;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#xFF1A;</p>
<ul>
<li>j &#x4E0B;&#x79FB;&#x5149;&#x6807;</li>
<li>k &#x4E0A;&#x79FB;&#x5149;&#x6807;</li>
<li>h &#x5DE6;&#x79FB;&#x5149;&#x6807;</li>
<li>l &#x53F3;&#x79FB;&#x5149;&#x6807;</li>
</ul>
<p>&#x5982;&#x679C;&#x7528;&#x7684;&#x4E0D;&#x4E60;&#x60EF;&#xFF0C;&#x4E0A;&#x4E0B;&#x5DE6;&#x53F3;&#x65B9;&#x5411;&#x952E;&#x4E5F;&#x53EF;&#x4EE5;&#x79FB;&#x52A8;&#x5149;&#x6807;&#x3002;</p>
<p><strong>&#x7F16;&#x8F91;&#x6A21;&#x5F0F;</strong></p>
<p>&#x5728;&#x4E00;&#x822C;&#x6A21;&#x5F0F;&#x4E0B;&#xFF0C;&#x8F93;&#x5165; a i o &#x53EF;&#x4EE5;&#x8FDB;&#x5165;&#x7F16;&#x8F91;&#x6A21;&#x5F0F;&#xFF0C;&#x7F16;&#x8F91;&#x6A21;&#x5F0F;&#x4E0B;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x8F93;&#x5165;&#x6587;&#x672C;&#x4FEE;&#x6539;&#x6587;&#x4EF6;&#x5185;&#x5BB9;&#x3002;</p>
<p>a i o &#x7684;&#x533A;&#x522B;&#x5982;&#x4E0B;:</p>
<ul>
<li>a&#xFF1A;&#x5728;&#x5F53;&#x524D;&#x5149;&#x6807;&#x4E0B;&#x4E00;&#x4F4D;&#x63D2;&#x5165;</li>
<li>i&#xFF1A;&#x5F53;&#x524D;&#x5149;&#x6807;&#x5904;&#x63D2;&#x5165;</li>
<li>o&#xFF1A;&#x6362;&#x884C;&#x5E76;&#x521B;&#x5EFA;&#x5168;&#x65B0;&#x7A7A;&#x767D;&#x884C;&#xFF0C;&#x5E76;&#x5728;&#x884C;&#x9996;&#x63D2;&#x5165;</li>
</ul>
<p>&#x5728;&#x7F16;&#x8F91;&#x6A21;&#x5F0F;&#x4E0B;&#xFF0C;&#x6211;&#x4EEC;&#x70B9;&#x51FB; esc &#x952E;&#x5373;&#x53EF;&#x56DE;&#x5230;&#x4E00;&#x822C;&#x6A21;&#x5F0F;&#x3002;</p>
<p><strong>&#x547D;&#x4EE4;&#x884C;&#x6A21;&#x5F0F;</strong></p>
<p>&#x5728;&#x4E00;&#x822C;&#x6A21;&#x5F0F;&#x4E0B;&#xFF0C;&#x8F93;&#x5165;&#x5206;&#x53F7;&#xFF0C;&#x5C31;&#x4F1A;&#x8FDB;&#x5165;&#x547D;&#x4EE4;&#x884C;&#x6A21;&#x5F0F;&#x3002;&#x5728;&#x547D;&#x4EE4;&#x884C;&#x4E2D;&#xFF0C;&#x53EF;&#x4EE5;&#x8F93;&#x5165;&#x4E0D;&#x540C;&#x7684;&#x6307;&#x4EE4;&#x6216;&#x8005;&#x5B57;&#x7B26;&#x4E32;&#x4EE5;&#x5B9E;&#x73B0;&#x4E0D;&#x540C;&#x7684;&#x529F;&#x80FD;&#x3002;&#x5176;&#x4E2D;&#x6D89;&#x53CA;&#x7684;&#x6700;&#x5E38;&#x7528;&#x7684;&#x529F;&#x80FD;&#x5305;&#x62EC;&#x4E86;&#x4E24;&#x7C7B;&#xFF1A;</p>
<ul>
<li>&#x9000;&#x51FA; vim</li>
<li>&#x5F53;&#x524D;&#x6587;&#x672C;&#x4E2D;&#xFF0C;&#x641C;&#x7D22;&#x5B57;&#x7B26;&#x4E32;</li>
</ul>
<p>&#x8FDB;&#x5165;&#x547D;&#x4EE4;&#x884C;&#x6A21;&#x5F0F;&#x540E;&#xFF0C;&#x6709;&#x4E09;&#x79CD;&#x65B9;&#x5F0F;&#x6765;&#x9000;&#x51FA; vim&#xFF1A;</p>
<ul>
<li>&#x5F53;&#x524D;&#x6587;&#x4EF6;&#x6CA1;&#x6709;&#x505A;&#x4EFB;&#x4F55;&#x6539;&#x53D8;&#x65F6;&#xFF0C;&#x8F93;&#x5165; <code>q</code> &#x6307;&#x4EE4;&#xFF0C;&#x9000;&#x51FA; vim &#x73AF;&#x5883;</li>
<li>&#x5F53;&#x524D;&#x6587;&#x4EF6;&#x505A;&#x4E86;&#x4E00;&#x4E9B;&#x4FEE;&#x6539;&#xFF0C;&#x5982;&#x679C;&#x60F3;&#x653E;&#x5F03;&#x5DF2;&#x4FEE;&#x6539;&#x7684;&#x5185;&#x5BB9;&#xFF0C;&#x8F93;&#x5165; <code>q!</code> &#x6307;&#x4EE4;&#xFF0C;&#x9000;&#x51FA; vim &#x73AF;&#x5883;</li>
<li>&#x5F53;&#x524D;&#x6587;&#x4EF6;&#x505A;&#x4E86;&#x4E00;&#x4E9B;&#x4FEE;&#x6539;&#xFF0C;&#x5982;&#x679C;&#x60F3;&#x4FDD;&#x5B58;&#x5DF2;&#x4FEE;&#x6539;&#x7684;&#x5185;&#x5BB9;&#xFF0C;&#x8F93;&#x5165; <code>wq</code> &#x6307;&#x4EE4;&#xFF0C;&#x9000;&#x51FA; vim &#x73AF;&#x5883;</li>
</ul>
<p>&#x8FDB;&#x5165;&#x547D;&#x4EE4;&#x884C;&#x6A21;&#x5F0F;&#x540E;&#xFF0C;&#x6211;&#x4EEC;&#x8FD8;&#x53EF;&#x4EE5;&#x8F93;&#x5165; <code>/</code> + &#x5B57;&#x7B26;&#x4E32;&#xFF0C;&#x70B9;&#x51FB;&#x56DE;&#x8F66;&#x952E;&#xFF0C;&#x8FDB;&#x5165;&#x641C;&#x7D22;&#x6A21;&#x5F0F;&#xFF0C;&#x70B9;&#x51FB; N &#x952E;&#xFF0C;&#x5149;&#x6807;&#x5C31;&#x4F1A;&#x5728;&#x5339;&#x914D;&#x5904;&#x4F9D;&#x6B21;&#x8DF3;&#x52A8;&#x3002;</p>
<p>&#x5728;&#x4E00;&#x822C;&#x6A21;&#x5F0F;&#x4E0B;&#xFF0C;&#x6211;&#x4EEC;&#x4E5F;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x8F93;&#x5165; <code>/</code> + &#x5B57;&#x7B26;&#x4E32;&#x8FDB;&#x884C;&#x641C;&#x7D22;&#x3002;</p>
<p><strong>vim &#x57FA;&#x672C;&#x4F7F;&#x7528;&#x5C0F;&#x7ED3;</strong></p>
<p>vim &#x7F16;&#x8F91;&#x5668;&#x7684;&#x4E09;&#x79CD;&#x6A21;&#x5F0F;&#x95F4;&#x5207;&#x6362;&#x5982;&#x4E0B;&#x56FE;&#x6240;&#x793A;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230224141446.png" alt></p>
<h3 class="mume-header" id="3-find--grep-%E5%91%BD%E4%BB%A4">3. find + grep &#x547D;&#x4EE4;</h3>

<p>Android &#x7CFB;&#x7EDF;&#x6E90;&#x7801;&#x7E41;&#x6742;&#xFF0C;&#x901A;&#x5E38;&#x6211;&#x4EEC;&#x901A;&#x8FC7; find &#x547D;&#x4EE4;&#x6765;&#x67E5;&#x627E;&#x6211;&#x4EEC;&#x5173;&#x5FC3;&#x7684;&#x6587;&#x4EF6;&#x3002;&#x4F7F;&#x7528; find + grep &#x547D;&#x4EE4;&#x67E5;&#x627E;&#x6211;&#x4EEC;&#x5173;&#x5FC3;&#x7684;&#x6587;&#x4EF6;&#x5185;&#x5BB9;&#x3002;</p>
<ul>
<li>&#x627E;&#x6587;&#x4EF6;&#xFF0C;&#x6BD4;&#x5982; service_manager.c</li>
</ul>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token function">find</span> <span class="token builtin class-name">.</span> -name <span class="token string">&quot;service_manager.c&quot;</span>
./frameworks/native/cmds/servicemanager/service_manager.c
</pre><ul>
<li>&#x627E;&#x6587;&#x4EF6;&#x5185;&#x5BB9;&#xFF0C;&#x627E; recyclerview &#x5E93;</li>
</ul>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token function">find</span> <span class="token builtin class-name">.</span> -name <span class="token string">&quot;Android.bp&quot;</span> <span class="token operator">|</span> <span class="token function">xargs</span> <span class="token function">grep</span> <span class="token string">&quot;name: <span class="token entity" title="\&quot;">\&quot;</span>.*recyclerview.*<span class="token entity" title="\&quot;">\&quot;</span>&quot;</span>
./prebuilts/sdk/current/androidx/Android.bp:    name: <span class="token string">&quot;androidx.recyclerview_recyclerview-selection-nodeps&quot;</span>,
./prebuilts/sdk/current/androidx/Android.bp:    name: <span class="token string">&quot;androidx.recyclerview_recyclerview-selection&quot;</span>,
./prebuilts/sdk/current/androidx/Android.bp:    name: <span class="token string">&quot;androidx.recyclerview_recyclerview-nodeps&quot;</span>,
./prebuilts/sdk/current/androidx/Android.bp:    name: <span class="token string">&quot;androidx.recyclerview_recyclerview&quot;</span>,
./prebuilts/sdk/current/support/Android.bp:    name: <span class="token string">&quot;android-support-recyclerview-selection-nodeps&quot;</span>,
./prebuilts/sdk/current/support/Android.bp:    name: <span class="token string">&quot;android-support-recyclerview-selection&quot;</span>,
./prebuilts/sdk/current/support/Android.bp:    name: <span class="token string">&quot;android-support-v7-recyclerview-nodeps&quot;</span>,
./prebuilts/sdk/current/support/Android.bp:    name: <span class="token string">&quot;android-support-v7-recyclerview&quot;</span>,
</pre><h3 class="mume-header" id="4-samba-%E6%9C%8D%E5%8A%A1%E5%99%A8%E6%90%AD%E5%BB%BA">4. Samba &#x670D;&#x52A1;&#x5668;&#x642D;&#x5EFA;</h3>

<p>Samba &#x662F;&#x4E00;&#x6B3E;&#x6570;&#x636E;&#x5171;&#x4EAB;&#x7684;&#x8F6F;&#x4EF6;&#xFF0C;&#x53EF;&#x7528;&#x4E8E; Ubuntu &#x4E0E; Windows &#x4E4B;&#x95F4;&#x5171;&#x4EAB;&#x6E90;&#x4EE3;&#x7801;&#xFF0C;&#x4F20;&#x8F93;&#x6587;&#x4EF6;&#x3002;</p>
<p>Ubuntu &#x5B89;&#x88C5; samba &#x670D;&#x52A1;&#x7AEF;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token function">sudo</span> <span class="token function">apt</span> <span class="token function">install</span> samba
</pre><p>&#x914D;&#x7F6E; samba&#xFF0C;&#x4FEE;&#x6539; /etc/samba/smb.conf&#xFF0C;&#x6DFB;&#x52A0;&#x5982;&#x4E0B;&#x5185;&#x5BB9;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token punctuation">[</span>Project<span class="token punctuation">]</span>
        comment <span class="token operator">=</span> project
        path <span class="token operator">=</span> /home/zzh0838/Project <span class="token comment">#&#x4F60;&#x81EA;&#x5DF1;&#x9700;&#x8981;&#x5171;&#x4EAB;&#x7684;&#x76EE;&#x5F55;</span>
        browseable <span class="token operator">=</span> <span class="token function">yes</span>
        writable <span class="token operator">=</span> <span class="token function">yes</span>
</pre><p>&#x540E;&#x7EED;&#x64CD;&#x4F5C;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token function">chmod</span> <span class="token number">777</span> /home/zzh0838/Project
<span class="token function">sudo</span> smbpasswd -a username <span class="token comment">#&#x8FD9;&#x91CC;&#x662F;&#x5F53;&#x524D;&#x7528;&#x6237;&#x540D;</span>
<span class="token function">sudo</span> systemctl <span class="token builtin class-name">enable</span> smbd <span class="token comment">#samba &#x5F00;&#x673A;&#x81EA;&#x542F;&#x52A8;</span>
<span class="token function">sudo</span> systemctl restart smbd <span class="token comment">#&#x91CD;&#x542F; samba </span>
</pre><p>windows &#x8BBF;&#x95EE; Ubuntu &#x5171;&#x4EAB;&#x7684;&#x6587;&#x4EF6;&#x952E;&#xFF1A;</p>
<p>win &#x952E;&#x52A0; R &#x952E;&#xFF0C;&#x8DF3;&#x51FA;&#x8FD0;&#x884C;&#x7A97;&#x53E3;&#xFF0C;&#x8F93;&#x5165; <code>\\10.0.0.89</code>&#xFF0C;&#x5176;&#x4E2D; <code>10.0.0.89</code> &#x662F;&#x6211;&#x7684; ubuntu &#x7684; IP &#x5730;&#x5740;&#xFF0C;&#x4F60;&#x9700;&#x8981;&#x6839;&#x636E;&#x4F60;&#x81EA;&#x5DF1;&#x7684;&#x60C5;&#x51B5;&#x4FEE;&#x6539;&#x4E3A;&#x81EA;&#x5DF1;&#x7684; Ubuntu &#x7684; IP &#x5730;&#x5740;&#x3002;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230330224915.png" alt></p>
<p>&#x70B9;&#x51FB;&#x786E;&#x5B9A;&#xFF0C;&#x5373;&#x53EF;&#x8BBF;&#x95EE;&#x5230; Ubuntu &#x4E2D;&#x5171;&#x4EAB;&#x7684;&#x6587;&#x4EF6;&#x4E86;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230330225704.png" alt></p>
<p>&#x53CC;&#x51FB; Project&#xFF0C;&#x8FDB;&#x5165;&#x5230;&#x4E0B;&#x9762;&#x7684;&#x6587;&#x4EF6;&#x5939;&#x4E2D;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230330225744.png" alt></p>
<h3 class="mume-header" id="5-vscode">5. VSCode</h3>

<p>VSCode &#x662F;&#x4E00;&#x6B3E;&#x5FAE;&#x8F6F;&#x63A8;&#x51FA;&#x7684;&#x6587;&#x672C;&#x7F16;&#x8F91;&#x5668;&#xFF0C;&#x540C;&#x4E2A;&#x5B83;&#x7684;&#x63D2;&#x4EF6;&#x7CFB;&#x7EDF;&#x53EF;&#x4EE5;&#x5B9E;&#x73B0;&#x7C7B; ide &#x7684;&#x4F53;&#x9A8C;&#xFF0C;&#x5728;&#x529F;&#x80FD;&#x6027;&#x548C;&#x9002;&#x5E94;&#x6027;&#x89D2;&#x5EA6;&#xFF0C;&#x975E;&#x5E38;&#x9002;&#x5408;&#x7528;&#x4E8E; Android &#x7CFB;&#x7EDF;&#x5F00;&#x53D1;&#x3002;</p>
<p>&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x4E24;&#x79CD;&#x65B9;&#x5F0F;&#x6765;&#x4F7F;&#x7528; VSCode</p>
<ul>
<li>Ubuntu &#x672C;&#x673A;&#x4F7F;&#x7528;</li>
<li>Windows &#x901A;&#x8FC7; remote-ssh &#x63D2;&#x4EF6;&#x8FDC;&#x7A0B;&#x4F7F;&#x7528; VSCode &#x7F16;&#x8F91;linux &#x4E0A;&#x7684;&#x4EE3;&#x7801;</li>
</ul>
<h4 class="mume-header" id="51-ubuntu-%E6%9C%AC%E6%9C%BA%E4%BD%BF%E7%94%A8">5.1 Ubuntu &#x672C;&#x673A;&#x4F7F;&#x7528;</h4>

<p>&#x9996;&#x5148;&#x662F;&#x5B89;&#x88C5; VScode&#xFF0C;&#x5728;<a href="https://code.visualstudio.com/">&#x5B98;&#x7F51;</a>&#x4E0B;&#x8F7D;&#x597D; deb &#x683C;&#x5F0F;&#x7684;&#x5B89;&#x88C5;&#x5305;&#xFF0C;&#x63A5;&#x7740;&#x5B89;&#x88C5;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token function">sudo</span> dpkg -i code_1.76.2-1678817801_amd64.deb
</pre><p>&#x8FD9;&#x6837;&#x6211;&#x4EEC;&#x5C31;&#x53EF;&#x4EE5;&#x4F7F;&#x7528; vscode &#x4E86;&#xFF0C;&#x6211;&#x4EEC;&#x6253;&#x5F00; vscode&#xFF0C;&#x7136;&#x540E;&#x901A;&#x8FC7; file -&gt; open folder &#x9009;&#x62E9;&#x6211;&#x4EEC;&#x7684;&#x7CFB;&#x7EDF;&#x6E90;&#x7801;&#xFF0C;&#x5373;&#x53EF;&#x6253;&#x5F00;&#x6574;&#x4E2A;&#x7CFB;&#x7EDF;&#x6E90;&#x7801;&#x3002;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230331003748.png" alt></p>
<p>&#x5F53;&#x7136;&#xFF0C;&#x6211;&#x4EEC;&#x6839;&#x636E;&#x9700;&#x8981;&#x53EA;&#x6253;&#x5F00;&#x6211;&#x4EEC;&#x5173;&#x5FC3;&#x7684;&#x6A21;&#x5757;&#x3002;</p>
<p>&#x53E6;&#x5916;&#x4E3A;&#x4E86;&#x4F7F;&#x6211;&#x4EEC;&#x7684; vscode &#x66F4;&#x597D;&#x7528;&#x66F4;&#x597D;&#x770B;&#xFF0C;&#x901A;&#x5E38;&#x6211;&#x4EEC;&#x4F1A;&#x5B89;&#x88C5;&#x4E00;&#x4E0B;&#x4E00;&#x4E9B;&#x63D2;&#x4EF6;&#xFF1A;</p>
<ul>
<li>C/C++ Extension Pack</li>
<li>Extension Pack for Java</li>
<li>Makefile Tools</li>
<li>RC Script language</li>
<li>Android System Tools</li>
<li>Android Studio Color Theme</li>
</ul>
<h4 class="mume-header" id="52-%E8%BF%9C%E7%A8%8B%E4%BD%BF%E7%94%A8">5.2 &#x8FDC;&#x7A0B;&#x4F7F;&#x7528;</h4>

<p>&#x5728; Windows &#x4E0B;&#xFF0C;&#x6211;&#x4EEC;&#x4E5F;&#x53EF;&#x4EE5;&#x901A;&#x8FC7; VSCode &#x7684; remote-ssh &#x63D2;&#x4EF6;&#x8FDC;&#x7A0B;&#x4FEE;&#x6539;&#x6211;&#x4EEC;&#x7684;&#x7CFB;&#x7EDF;&#x6E90;&#x7801;&#x3002;</p>
<p>&#x9996;&#x5148;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x5728;<a href="https://code.visualstudio.com/">&#x5B98;&#x7F51;</a>&#x4E0B;&#x8F7D;&#x597D; VSCode &#x7684;&#x5B89;&#x88C5;&#x5305;&#xFF0C;&#x7136;&#x540E;&#x6253;&#x5F00;&#x5B89;&#x88C5;&#x5305;&#x72C2;&#x70B9;&#x4E0B;&#x4E00;&#x6B65;&#x5373;&#x53EF;&#x5B89;&#x88C5;&#x597D; VSCode&#x3002;</p>
<p>&#x63A5;&#x7740;&#x5728;&#x63D2;&#x4EF6;&#x5E02;&#x573A;&#x4E2D;&#x5B89;&#x88C5;&#x597D; Remote-SSH &#x63D2;&#x4EF6;&#x3002;</p>
<p>&#x63A5;&#x7740;&#x5C31;&#x53EF;&#x4EE5;&#x914D;&#x7F6E; SSH &#x8FDC;&#x7A0B;&#x8FDE;&#x63A5;&#x4E86;&#xFF1A;</p>
<p>&#x70B9;&#x51FB;&#x5DE6;&#x4FA7; remote-explorer &#x56FE;&#x6807;&#xFF0C;&#x70B9;&#x51FB;&#x53F3;&#x4FA7;&#x52A0;&#x53F7;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230331084430.png" alt></p>
<p>&#x5728;&#x5F39;&#x51FA;&#x7684;&#x8F93;&#x5165;&#x6846;&#x4E2D;&#xFF0C;&#x8F93;&#x5165; <code>&#x7528;&#x6237;&#x540D;@IP&#x5730;&#x5740;</code>&#xFF0C;&#x70B9;&#x51FB;&#x56DE;&#x8F66;&#x3002;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230331084625.png" alt></p>
<p>&#x63A5;&#x7740;&#xFF0C;&#x9009;&#x62E9;&#x7B2C;&#x4E00;&#x4E2A;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#xFF0C;&#x70B9;&#x51FB;&#x56DE;&#x8F66;&#x3002;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230331084721.png" alt></p>
<p>&#x63A5;&#x7740;&#xFF0C;&#x5DE6;&#x4FA7;&#x7684;&#x6E05;&#x5355;&#x4E2D;&#x5C31;&#x4F1A;&#x51FA;&#x73B0;&#x6211;&#x4EEC;&#x914D;&#x7F6E;&#x7684; 10.0.0.89,&#x70B9;&#x51FB;&#x53F3;&#x4FA7;&#x6709;&#x4E2A;&#x52A0;&#x53F7;&#x7684;&#x6587;&#x4EF6;&#x56FE;&#x6807;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230331092230.png" alt></p>
<p>&#x5F39;&#x51FA;&#x65B0;&#x7684; VSCode &#x7A97;&#x53E3;&#xFF0C;&#x6211;&#x4EEC;&#x70B9;&#x51FB; File -&gt; Open Folder&#xFF0C;&#x7136;&#x540E;&#x9009;&#x62E9;&#x6211;&#x4EEC;&#x7684;&#x6E90;&#x7801;&#x8DEF;&#x5F84;&#x5373;&#x53EF;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230331092351.png" alt></p>
<p>&#x6253;&#x5F00;&#x7684;&#x8FC7;&#x7A0B;&#x4E2D;&#xFF0C;&#x9700;&#x8981;&#x6211;&#x4EEC;&#x8F93;&#x5165; Ubuntu &#x7684;&#x767B;&#x5F55;&#x5BC6;&#x7801;&#x3002;&#x6211;&#x4EEC;&#x4E5F;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x914D;&#x7F6E;&#xFF0C;&#x5B9E;&#x73B0;&#x514D;&#x5BC6;&#x767B;&#x5F55;&#x7684;&#x6548;&#x679C;&#xFF1A;</p>
<p>&#x6253;&#x5F00; win &#x4E0A;&#x7684; PowerShell&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token comment"># &#x751F;&#x6210;&#x516C;&#x94A5;</span>
ssh-keygen -t rsa
<span class="token function">cat</span> ~/.ssh/id_rsa.pub
</pre><p>&#x5C06;&#x516C;&#x94A5;&#x6587;&#x4EF6;&#x7684;&#x5185;&#x5BB9;&#x62F7;&#x8D1D;&#x5230; ubuntu &#x7684; ~/.ssh/authorized_keys &#x4E2D;</p>
<p>ubuntu &#x91CD;&#x542F; ssh &#x670D;&#x52A1;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token function">sudo</span> systemctl restart <span class="token function">ssh</span>
</pre><h3 class="mume-header" id="6-adb">6. adb</h3>

<p>&#x6700;&#x540E;&#xFF0C;&#x6211;&#x4EEC;&#x5728;&#x4ECB;&#x7ECD; adb &#x7684;&#x4E24;&#x4E2A;&#x5E38;&#x7528;&#x529F;&#x80FD;</p>
<ul>
<li>adb push&#xFF1A;&#x5C06;&#x5F00;&#x53D1;&#x673A;&#x4E0A;&#x7684;&#x6587;&#x4EF6;&#x4E0A;&#x4F20;&#x5230; Android &#x673A;&#x5668;&#x4E0A;</li>
</ul>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token function">touch</span> testfile
<span class="token comment"># &#x4E00;&#x4E9B;&#x4E34;&#x65F6;&#x6587;&#x4EF6;</span>
adb push ./testfile /data/local/tmp
</pre><ul>
<li>adb shell&#xFF1A;&#x7528;&#x4E8E;&#x8FDB;&#x5165; Android &#x7684; shell &#x7EC8;&#x7AEF;</li>
</ul>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230331093004.png" alt></p>
<h2 class="mume-header" id="%E7%AC%AC%E4%B8%89%E7%AB%A0-%E6%B7%BB%E5%8A%A0-product">&#x7B2C;&#x4E09;&#x7AE0; &#x6DFB;&#x52A0; Product</h2>

<h3 class="mume-header" id="1-%E4%BB%80%E4%B9%88%E6%98%AF-product">1. &#x4EC0;&#x4E48;&#x662F; Product</h3>

<p>&#x5728; App &#x7684;&#x5F00;&#x53D1;&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x8981;&#x53BB;&#x6253;&#x6E20;&#x9053;&#x5305;&#xFF0C;&#x6839;&#x636E;&#x4E0D;&#x540C;&#x5E94;&#x7528;&#x5E02;&#x573A;&#x7684;&#x8981;&#x6C42;&#x6253;&#x5305;&#x51FA;&#x4E0D;&#x540C;&#x7684; apk &#x5305;&#x3002;</p>
<p>&#x540C;&#x6837;&#x7684;&#x9053;&#x7406;&#xFF0C;Android &#x7684;&#x7CFB;&#x7EDF;&#x6E90;&#x7801;&#xFF0C;&#x7ECF;&#x8FC7;&#x7B80;&#x5355;&#x7684;&#x914D;&#x7F6E;&#xFF0C;&#x53EF;&#x4EE5;&#x6253;&#x5305;&#x51FA;&#x4E0D;&#x540C;&#x7684;&#x7CFB;&#x7EDF;&#x955C;&#x50CF;&#xFF0C;&#x7528;&#x4E8E;&#x4E0D;&#x540C;&#x7684;&#x4EA7;&#x54C1;&#x3002;&#x4F8B;&#x5982;&#x5C0F;&#x7C73; 12s&#xFF0C;&#x5C0F;&#x7C73;12s pro&#xFF0C;&#x5C0F;&#x7C73;12s ultra &#x5747;&#x6E90;&#x4E8E;&#x9A81;&#x9F99;8+&#x5E73;&#x53F0;&#x3002;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230223201246.png" alt></p>
<p>Android &#x7CFB;&#x7EDF;&#x6E90;&#x7801;&#x662F;&#x901A;&#x8FC7;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x6765;&#x5B9E;&#x73B0; &#x201C;&#x5206;&#x5305;&#x201D; &#x7684;&#xFF0C;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x5C06;&#x6211;&#x4EEC;&#x7684;&#x6E90;&#x7801;&#x914D;&#x7F6E;&#x4E3A;&#x4E86;&#x4E0D;&#x540C;&#x7684; Product&#xFF0C;&#x6BCF;&#x4E00;&#x4E2A; Product &#x9002;&#x7528;&#x4E8E;&#x7279;&#x5B9A;&#x7684;&#x786C;&#x4EF6;&#x4EA7;&#x54C1;&#xFF0C;&#x8FD9;&#x4E00;&#x7CFB;&#x5217;&#x7684;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x6211;&#x4EEC;&#x79F0;&#x4E3A; <strong>Product</strong>&#x3002;</p>
<h3 class="mume-header" id="2-aosp-%E4%B8%AD%E9%A2%84%E5%88%B6%E7%9A%84-product">2. AOSP &#x4E2D;&#x9884;&#x5236;&#x7684; Product</h3>

<p>&#x6211;&#x4EEC;&#x5728;&#x7F16;&#x8BD1;&#x6E90;&#x7801;&#x4E4B;&#x524D;&#x9700;&#x8981;&#x6267;&#x884C; lunch &#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">lunch

You&apos;re building on Linux

Lunch menu<span class="token punctuation">..</span>. pick a combo:
     <span class="token number">1</span>. aosp_arm-eng
     <span class="token number">2</span>. aosp_arm64-eng
     <span class="token number">3</span>. aosp_blueline-userdebug
     <span class="token number">4</span>. aosp_bonito-userdebug
     <span class="token number">5</span>. aosp_car_arm-userdebug
     <span class="token number">6</span>. aosp_car_arm64-userdebug
     <span class="token number">7</span>. aosp_car_x86-userdebug
     <span class="token number">8</span>. aosp_car_x86_64-userdebug
     <span class="token number">9</span>. aosp_cf_arm64_phone-userdebug
     <span class="token number">10</span>. aosp_cf_x86_64_phone-userdebug
     <span class="token number">11</span>. aosp_cf_x86_auto-userdebug
     <span class="token number">12</span>. aosp_cf_x86_phone-userdebug
     <span class="token number">13</span>. aosp_cf_x86_tv-userdebug
     <span class="token number">14</span>. aosp_coral-userdebug
     <span class="token number">15</span>. aosp_coral_car-userdebug
     <span class="token number">16</span>. aosp_crosshatch-userdebug
     <span class="token number">17</span>. aosp_crosshatch_car-userdebug
     <span class="token number">18</span>. aosp_flame-userdebug
     <span class="token number">19</span>. aosp_marlin-userdebug
     <span class="token number">20</span>. aosp_sailfish-userdebug
     <span class="token number">21</span>. aosp_sargo-userdebug
     <span class="token number">22</span>. aosp_taimen-userdebug
     <span class="token number">23</span>. aosp_walleye-userdebug
     <span class="token number">24</span>. aosp_walleye_test-userdebug
     <span class="token number">25</span>. aosp_x86-eng
     <span class="token number">26</span>. aosp_x86_64-eng
     <span class="token number">27</span>. beagle_x15-userdebug
     <span class="token number">28</span>. car_x86_64-userdebug
     <span class="token number">29</span>. fuchsia_arm64-eng
     <span class="token number">30</span>. fuchsia_x86_64-eng
     <span class="token number">31</span>. hikey-userdebug
     <span class="token number">32</span>. hikey64_only-userdebug
     <span class="token number">33</span>. hikey960-userdebug
     <span class="token number">34</span>. hikey960_tv-userdebug
     <span class="token number">35</span>. hikey_tv-userdebug
     <span class="token number">36</span>. m_e_arm-userdebug
     <span class="token number">37</span>. mini_emulator_arm64-userdebug
     <span class="token number">38</span>. mini_emulator_x86-userdebug
     <span class="token number">39</span>. mini_emulator_x86_64-userdebug
     <span class="token number">40</span>. poplar-eng
     <span class="token number">41</span>. poplar-user
     <span class="token number">42</span>. poplar-userdebug
     <span class="token number">43</span>. qemu_trusty_arm64-userdebug
     <span class="token number">44</span>. uml-userdebug

Which would you like? <span class="token punctuation">[</span>aosp_arm-eng<span class="token punctuation">]</span>
</pre><p>&#x8FD9;&#x91CC;&#x7684;&#x6BCF;&#x4E00;&#x4E2A;&#x9009;&#x9879;&#x5C31;&#x662F;&#x4E00;&#x4E2A; Product&#xFF0C; AOSP &#x9884;&#x5236;&#x4E86;&#x5F88;&#x591A; Product&#x3002;&#x5BF9;&#x5E94;&#x4E8E; x86_64 &#x6A21;&#x62DF;&#x5668;&#xFF0C;&#x6211;&#x4EEC;&#x9009;&#x62E9;&#x7684;&#x662F; aosp_x86_64-eng&#x3002;</p>
<p>AOSP &#x4E2D; Product &#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4FDD;&#x5B58;&#x5728;&#x4EE5;&#x4E0B;&#x4E24;&#x4E2A;&#x76EE;&#x5F55;&#xFF1A;</p>
<ul>
<li>build/target&#xFF1A;aosp &#x63D0;&#x4F9B;&#x7684; product &#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4FDD;&#x5B58;&#x5728;&#x8FD9;&#x4E2A;&#x76EE;&#x5F55;&#x4E0B;&#xFF0C;&#x6211;&#x4EEC;&#x9009;&#x62E9;&#x7684; aosp_x86_64-eng Product &#x5C31;&#x914D;&#x7F6E;&#x5728;&#x8FD9;&#x4E2A;&#x76EE;&#x5F55;&#x4E0B;&#x3002;</li>
<li>device&#xFF1A;&#x82AF;&#x7247;&#x53CA;&#x65B9;&#x6848;&#x5382;&#x5546;&#x63D0;&#x4F9B;&#x7684; product &#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4FDD;&#x5B58;&#x5728;&#x8FD9;&#x4E2A;&#x76EE;&#x5F55;&#x4E0B;</li>
</ul>
<p>&#x5148;&#x4F7F;&#x7528; tree &#x547D;&#x4EE4;&#x67E5;&#x770B; build/target &#x57FA;&#x672C;&#x7684;&#x76EE;&#x5F55;&#x7ED3;&#x6784;:</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">tree <span class="token builtin class-name">.</span> -L <span class="token number">2</span>
<span class="token builtin class-name">.</span>
&#x251C;&#x2500;&#x2500; board
&#x2502;   &#x251C;&#x2500;&#x2500; Android.mk
&#x2502;   &#x251C;&#x2500;&#x2500; BoardConfigEmuCommon.mk
&#x2502;   &#x251C;&#x2500;&#x2500; BoardConfigGsiCommon.mk
&#x2502;   &#x251C;&#x2500;&#x2500; BoardConfigMainlineCommon.mk
&#x2502;   &#x251C;&#x2500;&#x2500; BoardConfigModuleCommon.mk
&#x2502;   &#x251C;&#x2500;&#x2500; BoardConfigPixelCommon.mk
&#x2502;   &#x251C;&#x2500;&#x2500; emulator_arm
&#x2502;   &#x251C;&#x2500;&#x2500; emulator_arm64
&#x2502;   &#x251C;&#x2500;&#x2500; emulator_x86
&#x2502;   &#x251C;&#x2500;&#x2500; emulator_x86_64
&#x2502;   &#x251C;&#x2500;&#x2500; emulator_x86_64_arm64
&#x2502;   &#x251C;&#x2500;&#x2500; emulator_x86_arm
&#x2502;   &#x251C;&#x2500;&#x2500; generic
&#x2502;   &#x251C;&#x2500;&#x2500; generic_64bitonly_x86_64
&#x2502;   &#x251C;&#x2500;&#x2500; generic_arm64
&#x2502;   &#x251C;&#x2500;&#x2500; generic_x86
&#x2502;   &#x251C;&#x2500;&#x2500; generic_x86_64
&#x2502;   &#x251C;&#x2500;&#x2500; generic_x86_64_arm64
&#x2502;   &#x251C;&#x2500;&#x2500; generic_x86_arm
&#x2502;   &#x251C;&#x2500;&#x2500; go_defaults_512.prop
&#x2502;   &#x251C;&#x2500;&#x2500; go_defaults_common.prop
&#x2502;   &#x251C;&#x2500;&#x2500; go_defaults.prop
&#x2502;   &#x251C;&#x2500;&#x2500; gsi_arm64
&#x2502;   &#x251C;&#x2500;&#x2500; gsi_system_ext.prop
&#x2502;   &#x251C;&#x2500;&#x2500; gsi_system_ext_user.prop
&#x2502;   &#x251C;&#x2500;&#x2500; mainline_arm64
&#x2502;   &#x251C;&#x2500;&#x2500; mainline_sdk
&#x2502;   &#x251C;&#x2500;&#x2500; mainline_x86
&#x2502;   &#x251C;&#x2500;&#x2500; mainline_x86_64
&#x2502;   &#x251C;&#x2500;&#x2500; mainline_x86_arm
&#x2502;   &#x251C;&#x2500;&#x2500; module_arm
&#x2502;   &#x251C;&#x2500;&#x2500; module_arm64
&#x2502;   &#x251C;&#x2500;&#x2500; module_x86
&#x2502;   &#x251C;&#x2500;&#x2500; module_x86_64
&#x2502;   &#x2514;&#x2500;&#x2500; ndk
&#x251C;&#x2500;&#x2500; OWNERS
&#x2514;&#x2500;&#x2500; product
    &#x251C;&#x2500;&#x2500; AndroidProducts.mk
    &#x251C;&#x2500;&#x2500; aosp_64bitonly_x86_64.mk
    &#x251C;&#x2500;&#x2500; aosp_arm64.mk
    &#x251C;&#x2500;&#x2500; aosp_arm.mk
    &#x251C;&#x2500;&#x2500; aosp_base.mk
    &#x251C;&#x2500;&#x2500; aosp_base_telephony.mk
    &#x251C;&#x2500;&#x2500; aosp_product.mk
    &#x251C;&#x2500;&#x2500; aosp_x86_64.mk
    &#x251C;&#x2500;&#x2500; aosp_x86_arm.mk
    &#x251C;&#x2500;&#x2500; aosp_x86.mk
    &#x251C;&#x2500;&#x2500; base.mk
    &#x251C;&#x2500;&#x2500; base_product.mk
    &#x251C;&#x2500;&#x2500; base_system_ext.mk
    &#x251C;&#x2500;&#x2500; base_system.mk
    &#x251C;&#x2500;&#x2500; base_vendor.mk
    &#x251C;&#x2500;&#x2500; cfi-common.mk
    &#x251C;&#x2500;&#x2500; core_64_bit.mk
    &#x251C;&#x2500;&#x2500; core_64_bit_only.mk
    &#x251C;&#x2500;&#x2500; core_minimal.mk
    &#x251C;&#x2500;&#x2500; core_no_zygote.mk
    &#x251C;&#x2500;&#x2500; default_art_config.mk
    &#x251C;&#x2500;&#x2500; developer_gsi_keys.mk
    &#x251C;&#x2500;&#x2500; empty-preloaded-classes
    &#x251C;&#x2500;&#x2500; empty-profile
    &#x251C;&#x2500;&#x2500; emulated_storage.mk
    &#x251C;&#x2500;&#x2500; emulator.mk
    &#x251C;&#x2500;&#x2500; emulator_system.mk
    &#x251C;&#x2500;&#x2500; emulator_vendor.mk
    &#x251C;&#x2500;&#x2500; full_base.mk
    &#x251C;&#x2500;&#x2500; full_base_telephony.mk
    &#x251C;&#x2500;&#x2500; full.mk
    &#x251C;&#x2500;&#x2500; full_x86.mk
    &#x251C;&#x2500;&#x2500; generic.mk
    &#x251C;&#x2500;&#x2500; generic_no_telephony.mk
    &#x251C;&#x2500;&#x2500; generic_ramdisk.mk
    &#x251C;&#x2500;&#x2500; generic_system_arm64.mk
    &#x251C;&#x2500;&#x2500; generic_system.mk
    &#x251C;&#x2500;&#x2500; generic_system_x86_64.mk
    &#x251C;&#x2500;&#x2500; generic_system_x86_arm.mk
    &#x251C;&#x2500;&#x2500; generic_system_x86.mk
    &#x251C;&#x2500;&#x2500; generic_x86.mk
    &#x251C;&#x2500;&#x2500; go_defaults_512.mk
    &#x251C;&#x2500;&#x2500; go_defaults_common.mk
    &#x251C;&#x2500;&#x2500; go_defaults.mk
    &#x251C;&#x2500;&#x2500; gsi
    &#x251C;&#x2500;&#x2500; gsi_release.mk
    &#x251C;&#x2500;&#x2500; handheld_product.mk
    &#x251C;&#x2500;&#x2500; handheld_system_ext.mk
    &#x251C;&#x2500;&#x2500; handheld_system.mk
    &#x251C;&#x2500;&#x2500; handheld_vendor.mk
    &#x251C;&#x2500;&#x2500; languages_default.mk
    &#x251C;&#x2500;&#x2500; languages_full.mk
    &#x251C;&#x2500;&#x2500; mainline_sdk.mk
    &#x251C;&#x2500;&#x2500; mainline_system_arm64.mk
    &#x251C;&#x2500;&#x2500; mainline_system.mk -<span class="token operator">&gt;</span> generic_system.mk
    &#x251C;&#x2500;&#x2500; mainline_system_x86_64.mk
    &#x251C;&#x2500;&#x2500; mainline_system_x86_arm.mk
    &#x251C;&#x2500;&#x2500; mainline_system_x86.mk
    &#x251C;&#x2500;&#x2500; media_product.mk
    &#x251C;&#x2500;&#x2500; media_system_ext.mk
    &#x251C;&#x2500;&#x2500; media_system.mk
    &#x251C;&#x2500;&#x2500; media_vendor.mk
    &#x251C;&#x2500;&#x2500; module_arm64.mk
    &#x251C;&#x2500;&#x2500; module_arm.mk
    &#x251C;&#x2500;&#x2500; module_common.mk
    &#x251C;&#x2500;&#x2500; module_x86_64.mk
    &#x251C;&#x2500;&#x2500; module_x86.mk
    &#x251C;&#x2500;&#x2500; ndk.mk
    &#x251C;&#x2500;&#x2500; non_ab_device.mk
    &#x251C;&#x2500;&#x2500; OWNERS
    &#x251C;&#x2500;&#x2500; product_launched_with_k.mk
    &#x251C;&#x2500;&#x2500; product_launched_with_l.mk
    &#x251C;&#x2500;&#x2500; product_launched_with_l_mr1.mk
    &#x251C;&#x2500;&#x2500; product_launched_with_m.mk
    &#x251C;&#x2500;&#x2500; product_launched_with_n.mk
    &#x251C;&#x2500;&#x2500; product_launched_with_n_mr1.mk
    &#x251C;&#x2500;&#x2500; product_launched_with_o.mk
    &#x251C;&#x2500;&#x2500; product_launched_with_o_mr1.mk
    &#x251C;&#x2500;&#x2500; product_launched_with_p.mk
    &#x251C;&#x2500;&#x2500; profile_boot_common.mk
    &#x251C;&#x2500;&#x2500; runtime_libart.mk
    &#x251C;&#x2500;&#x2500; sdk_arm64.mk
    &#x251C;&#x2500;&#x2500; sdk.mk
    &#x251C;&#x2500;&#x2500; sdk_phone_arm64.mk
    &#x251C;&#x2500;&#x2500; sdk_phone_armv7.mk
    &#x251C;&#x2500;&#x2500; sdk_phone_x86_64.mk
    &#x251C;&#x2500;&#x2500; sdk_phone_x86.mk
    &#x251C;&#x2500;&#x2500; sdk_x86_64.mk
    &#x251C;&#x2500;&#x2500; sdk_x86.mk
    &#x251C;&#x2500;&#x2500; security
    &#x251C;&#x2500;&#x2500; sysconfig
    &#x251C;&#x2500;&#x2500; telephony.mk
    &#x251C;&#x2500;&#x2500; telephony_product.mk
    &#x251C;&#x2500;&#x2500; telephony_system_ext.mk
    &#x251C;&#x2500;&#x2500; telephony_system.mk
    &#x251C;&#x2500;&#x2500; telephony_vendor.mk
    &#x251C;&#x2500;&#x2500; updatable_apex.mk
    &#x251C;&#x2500;&#x2500; userspace_reboot.mk
    &#x251C;&#x2500;&#x2500; vboot.mk
    &#x251C;&#x2500;&#x2500; verity.mk
    &#x251C;&#x2500;&#x2500; virtual_ab_ota
    &#x251C;&#x2500;&#x2500; virtual_ab_ota.mk -<span class="token operator">&gt;</span> virtual_ab_ota/launch.mk
    &#x251C;&#x2500;&#x2500; virtual_ab_ota_plus_non_ab.mk -<span class="token operator">&gt;</span> virtual_ab_ota/plus_non_ab.mk
    &#x2514;&#x2500;&#x2500; virtual_ab_ota_retrofit.mk -<span class="token operator">&gt;</span> virtual_ab_ota/retrofit.mk
</pre><p>board&#x76EE;&#x5F55;&#x4E0B;&#x4E3B;&#x8981;&#x662F;&#x4E00;&#x4E9B;&#x786C;&#x4EF6;&#x76F8;&#x5173;&#x7684;&#x914D;&#x7F6E;&#xFF0C; product &#x76EE;&#x5F55;&#x4E3B;&#x8981;&#x662F;&#x4EA7;&#x54C1;&#x76F8;&#x5173;&#x7684;&#x914D;&#x7F6E;</p>
<p>&#x9488;&#x5BF9;&#x6211;&#x4EEC;&#x9009;&#x62E9;&#x7684; aosp_x86_64-eng&#xFF0C;&#x6211;&#x4EEC;&#x4E3B;&#x8981;&#x5173;&#x6CE8;&#x4EE5;&#x4E0B;&#x51E0;&#x4E2A;&#x6587;&#x4EF6;&#xFF1A;</p>
<ul>
<li><code>/board/generic_x86_64/BoardConfig.mk</code> &#xFF1A; &#x7528;&#x4E8E;&#x786C;&#x4EF6;&#x76F8;&#x5173;&#x914D;&#x7F6E;</li>
<li><code>/product/AndroidProducts.mk</code>   <code>/product/aosp_x86_64.mk</code>&#xFF1A;&#x7528;&#x4E8E;&#x914D;&#x7F6E; Product</li>
</ul>
<p>&#x63A5;&#x4E0B;&#x6765;&#x6211;&#x4EEC;&#x6765;&#x770B;&#x770B;&#x8FD9;&#x4E09;&#x4E2A;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#xFF1A;</p>
<p><strong><a href="http://BoardConfig.mk">BoardConfig.mk</a></strong> &#x7528;&#x4E8E;&#x5B9A;&#x4E49;&#x548C;&#x786C;&#x4EF6;&#x76F8;&#x5173;&#x7684;&#x5E95;&#x5C42;&#x7279;&#x6027;&#x548C;&#x53D8;&#x91CF;&#xFF0C;&#x6BD4;&#x5982;&#x5F53;&#x524D;&#x6E90;&#x7801;&#x652F;&#x6301;&#x7684; cpu &#x4F4D;&#x6570;(64/32&#x4F4D;)&#xFF0C;bootloader &#x548C; kernel, &#x662F;&#x5426;&#x652F;&#x6301;&#x6444;&#x50CF;&#x5934;&#xFF0C;GPS&#x5BFC;&#x822A;&#x7B49;&#x4E00;&#x4E9B;&#x677F;&#x7EA7;&#x7279;&#x6027;&#x3002;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token comment"># x86_64 emulator specific definitions</span>
TARGET_CPU_ABI :<span class="token operator">=</span> x86_64
TARGET_ARCH :<span class="token operator">=</span> x86_64
TARGET_ARCH_VARIANT :<span class="token operator">=</span> x86_64

TARGET_2ND_CPU_ABI :<span class="token operator">=</span> x86
TARGET_2ND_ARCH :<span class="token operator">=</span> x86
TARGET_2ND_ARCH_VARIANT :<span class="token operator">=</span> x86_64

TARGET_PRELINK_MODULE :<span class="token operator">=</span> <span class="token boolean">false</span>
include build/make/target/board/BoardConfigGsiCommon.mk
include build/make/target/board/BoardConfigEmuCommon.mk

BOARD_USERDATAIMAGE_PARTITION_SIZE :<span class="token operator">=</span> <span class="token number">576716800</span>

BOARD_SEPOLICY_DIRS <span class="token operator">+=</span> device/generic/goldfish/sepolicy/x86

<span class="token comment"># Wifi.</span>
BOARD_WLAN_DEVICE           :<span class="token operator">=</span> emulator
BOARD_HOSTAPD_DRIVER        :<span class="token operator">=</span> NL80211
BOARD_WPA_SUPPLICANT_DRIVER :<span class="token operator">=</span> NL80211
BOARD_HOSTAPD_PRIVATE_LIB   :<span class="token operator">=</span> lib_driver_cmd_simulated
BOARD_WPA_SUPPLICANT_PRIVATE_LIB :<span class="token operator">=</span> lib_driver_cmd_simulated
WPA_SUPPLICANT_VERSION      :<span class="token operator">=</span> VER_0_8_X
WIFI_DRIVER_FW_PATH_PARAM   :<span class="token operator">=</span> <span class="token string">&quot;/dev/null&quot;</span>
WIFI_DRIVER_FW_PATH_STA     :<span class="token operator">=</span> <span class="token string">&quot;/dev/null&quot;</span>
WIFI_DRIVER_FW_PATH_AP      :<span class="token operator">=</span> <span class="token string">&quot;/dev/null&quot;</span>
</pre><p>&#x5176;&#x4E2D;&#x8FD8;&#x901A;&#x8FC7; include &#x5305;&#x542B;&#x4E86; <a href="http://BoardConfigGsiCommon.mk">BoardConfigGsiCommon.mk</a> &#x548C; <a href="http://BoardConfigEmuCommon.mk">BoardConfigEmuCommon.mk</a> &#x4E24;&#x4E2A;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#xFF0C;&#x524D;&#x8005;&#x7528;&#x4E8E;&#x901A;&#x7528;&#x7CFB;&#x7EDF;&#x6620;&#x50CF;&#x7684;&#x914D;&#x7F6E;&#xFF0C;&#x540E;&#x8005;&#x7528;&#x4E8E;&#x6A21;&#x62DF;&#x5668;&#x7684;&#x914D;&#x7F6E;</p>
<p>&#x4E3B;&#x8981;&#x548C;&#x786C;&#x4EF6;&#x76F8;&#x5173;&#xFF0C;&#x6709;&#x4E00;&#x4E2A;&#x57FA;&#x672C;&#x7684;&#x4E86;&#x89E3;&#x5373;&#x53EF;&#x3002;&#x4E00;&#x822C;&#x5F88;&#x5C11;&#x6539;&#x52A8;&#x3002;</p>
<p><strong><a href="http://AndroidProducts.mk">AndroidProducts.mk</a></strong> &#x5B9A;&#x4E49;&#x6211;&#x4EEC;&#x6267;&#x884C; lunch &#x547D;&#x4EE4;&#x65F6;&#xFF0C;&#x6253;&#x5370;&#x7684;&#x5217;&#x8868;&#x4EE5;&#x53CA;&#x6BCF;&#x4E2A;&#x9009;&#x9879;&#x5BF9;&#x5E94;&#x7684;&#x914D;&#x7F6E;&#x6587;&#x4EF6;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token comment"># Unbundled apps will be built with the most generic product config.</span>
<span class="token comment"># TARGET_BUILD_APPS &#x7F16;&#x8BD1;Android&#x7CFB;&#x7EDF;&#x65F6;&#xFF0C;&#x8FD9;&#x4E2A;&#x503C;&#x4E3A;&#x7A7A;&#xFF0C;&#x7F16;&#x8BD1;&#x5355;&#x6A21;&#x5757;&#x65F6;&#xFF0C;&#x8FD9;&#x4E2A;&#x503C;&#x4E3A;&#x6240;&#x7F16;&#x8BD1;&#x6A21;&#x5757;&#x7684;&#x8DEF;&#x5F84;</span>

<span class="token comment">#&#x7F16;&#x8BD1;&#x5355;&#x6A21;&#x5757;</span>
ifneq <span class="token punctuation">(</span><span class="token variable"><span class="token variable">$(</span>TARGET_BUILD_APPS<span class="token variable">)</span></span>,<span class="token punctuation">)</span>
PRODUCT_MAKEFILES :<span class="token operator">=</span> <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/aosp_arm64.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/aosp_arm.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/aosp_x86_64.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/aosp_x86.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/full.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/full_x86.mk <span class="token punctuation">\</span>
<span class="token comment">#&#x7F16;&#x8BD1;&#x7CFB;&#x7EDF;</span>
<span class="token keyword keyword-else">else</span>
PRODUCT_MAKEFILES :<span class="token operator">=</span> <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/aosp_64bitonly_x86_64.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/aosp_arm64.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/aosp_arm.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/aosp_x86_64.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/aosp_x86_arm.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/aosp_x86.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/full.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/full_x86.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/generic.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/generic_system_arm64.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/generic_system_x86.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/generic_system_x86_64.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/generic_system_x86_arm.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/generic_x86.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/mainline_system_arm64.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/mainline_system_x86.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/mainline_system_x86_64.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/mainline_system_x86_arm.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/ndk.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/sdk_arm64.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/sdk.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/sdk_phone_arm64.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/sdk_phone_armv7.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/sdk_phone_x86_64.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/sdk_phone_x86.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/sdk_x86_64.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/sdk_x86.mk <span class="token punctuation">\</span>

endif

PRODUCT_MAKEFILES <span class="token operator">+=</span> <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/mainline_sdk.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/module_arm.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/module_arm64.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/module_x86.mk <span class="token punctuation">\</span>
    <span class="token variable"><span class="token variable">$(</span>LOCAL_DIR<span class="token variable">)</span></span>/module_x86_64.mk <span class="token punctuation">\</span>

<span class="token comment"># &#x914D;&#x7F6E;&#x6211;&#x4EEC;&#x5728; lunch &#x65F6;&#x7684;&#x9009;&#x9879;</span>
COMMON_LUNCH_CHOICES :<span class="token operator">=</span> <span class="token punctuation">\</span>
    aosp_arm64-eng <span class="token punctuation">\</span>
    aosp_arm-eng <span class="token punctuation">\</span>
    aosp_x86_64-eng <span class="token punctuation">\</span>
    aosp_x86-eng <span class="token punctuation">\</span>
</pre><p>PRODUCT_MAKEFILES &#x7528;&#x4E8E;&#x5F15;&#x5165;&#x4EA7;&#x54C1;&#x7684;&#x914D;&#x7F6E;&#x6587;&#x4EF6;</p>
<p>COMMON_LUNCH_CHOICES &#x7528;&#x4E8E;&#x6DFB;&#x52A0; lunch &#x65F6;&#x7684;&#x9009;&#x9879;&#xFF0C;&#x9009;&#x9879;&#x7684;&#x540D;&#x5B57;&#x7531;&#x4E24;&#x90E8;&#x5206;&#x8FC7;&#x7A0B; <code>&#x4EA7;&#x54C1;&#x540D; + &#x6784;&#x5EFA;&#x6A21;&#x5F0F;</code>&#xFF1A;</p>
<ul>
<li>&#x4EA7;&#x54C1;&#x540D;&#x5C31;&#x662F; PRODUCT_MAKEFILES &#x4E2D;&#x5F15;&#x5165;&#x7684;&#x4EA7;&#x54C1;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x540D;&#x53BB;&#x6389; <code>.mk</code> &#x540E;&#x7F00;&#xFF0C;&#x4F8B;&#x5982; aosp_x86_64</li>
<li>&#x6784;&#x5EFA;&#x6A21;&#x5F0F;&#x6709;&#x4E09;&#x79CD;&#xFF1A;&#x7528;&#x6237;&#x6A21;&#x5F0F; user&#x3001;&#x7528;&#x6237;&#x8C03;&#x8BD5;&#x6A21;&#x5F0F; userdebug &#x548C;&#x5DE5;&#x7A0B;&#x6A21;&#x5F0F; eng</li>
</ul>
<p>&#x4E3B;&#x8981;&#x533A;&#x522B;&#x5982;&#x4E0B;&#xFF1A;&#x3001;</p>
<p><strong>&#x7528;&#x6237;&#x6A21;&#x5F0F; user</strong></p>
<ul>
<li>&#x4EC5;&#x5B89;&#x88C5;&#x6807;&#x7B7E;&#x4E3A; user &#x7684;&#x6A21;&#x5757;</li>
<li>&#x8BBE;&#x5B9A;&#x5C5E;&#x6027; ro.secure=1&#xFF0C;&#x6253;&#x5F00;&#x5B89;&#x5168;&#x68C0;&#x67E5;&#x529F;&#x80FD;</li>
<li>&#x8BBE;&#x5B9A;&#x5C5E;&#x6027; ro.debuggable=0&#xFF0C;&#x5173;&#x95ED;&#x5E94;&#x7528;&#x8C03;&#x8BD5;&#x529F;&#x80FD;</li>
<li>&#x9ED8;&#x8BA4;&#x5173;&#x95ED; adb &#x529F;&#x80FD;</li>
<li>&#x6253;&#x5F00; Proguard &#x6DF7;&#x6DC6;&#x5668;</li>
<li>&#x6253;&#x5F00; DEXPREOPT &#x9884;&#x5148;&#x7F16;&#x8BD1;&#x4F18;&#x5316;</li>
</ul>
<p><strong>&#x7528;&#x6237;&#x8C03;&#x8BD5;&#x6A21;&#x5F0F; userdebug</strong></p>
<ul>
<li>&#x5B89;&#x88C5;&#x6807;&#x7B7E;&#x4E3A; user&#x3001;debug &#x7684;&#x6A21;&#x5757;</li>
<li>&#x8BBE;&#x5B9A;&#x5C5E;&#x6027; ro.secure=1&#xFF0C;&#x6253;&#x5F00;&#x5B89;&#x5168;&#x68C0;&#x67E5;&#x529F;&#x80FD;</li>
<li>&#x8BBE;&#x5B9A;&#x5C5E;&#x6027; ro.debuggable=1&#xFF0C;&#x542F;&#x7528;&#x5E94;&#x7528;&#x8C03;&#x8BD5;&#x529F;&#x80FD;</li>
<li>&#x9ED8;&#x8BA4;&#x6253;&#x5F00; adb &#x529F;&#x80FD;</li>
<li>&#x6253;&#x5F00; Proguard &#x6DF7;&#x6DC6;&#x5668;</li>
<li>&#x6253;&#x5F00; DEXPREOPT &#x9884;&#x5148;&#x7F16;&#x8BD1;&#x4F18;&#x5316;</li>
</ul>
<p><strong>&#x5DE5;&#x7A0B;&#x6A21;&#x5F0F; eng</strong></p>
<ul>
<li>&#x5B89;&#x88C5;&#x6807;&#x7B7E;&#x4E3A; user&#x3001;debug&#x3001;eng &#x7684;&#x6A21;&#x5757;</li>
<li>&#x8BBE;&#x5B9A;&#x5C5E;&#x6027; ro.secure=0&#xFF0C;&#x5173;&#x95ED;&#x5B89;&#x5168;&#x68C0;&#x67E5;&#x529F;&#x80FD;</li>
<li>&#x8BBE;&#x5B9A;&#x5C5E;&#x6027; ro.debuggable=1&#xFF0C;&#x542F;&#x7528;&#x5E94;&#x7528;&#x8C03;&#x8BD5;&#x529F;&#x80FD;</li>
<li>&#x8BBE;&#x5B9A;&#x5C5E;&#x6027; ro.kernel.android.checkjni=1&#xFF0C;&#x542F;&#x7528; JNI &#x8C03;&#x7528;&#x68C0;&#x67E5;</li>
<li>&#x9ED8;&#x8BA4;&#x6253;&#x5F00; adb &#x529F;&#x80FD;</li>
<li>&#x5173;&#x95ED; Proguard &#x6DF7;&#x6DC6;&#x5668;</li>
<li>&#x5173;&#x95ED; DEXPREOPT &#x9884;&#x5148;&#x7F16;&#x8BD1;&#x4F18;&#x5316;</li>
</ul>
<p><strong>aosp_x86_64.mk</strong>&#xFF1A;&#x8FD9;&#x4E2A;&#x6587;&#x4EF6;&#x5C31;&#x662F;&#x6211;&#x4EEC;&#x4EA7;&#x54C1;&#x914D;&#x7F6E;&#x7684;&#x4E3B;&#x57FA;&#x5730;&#x3002;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">PRODUCT_USE_DYNAMIC_PARTITIONS :<span class="token operator">=</span> <span class="token boolean">true</span>

<span class="token comment"># The system image of aosp_x86_64-userdebug is a GSI for the devices with:</span>
<span class="token comment"># - x86 64 bits user space</span>
<span class="token comment"># - 64 bits binder interface</span>
<span class="token comment"># - system-as-root</span>
<span class="token comment"># - VNDK enforcement</span>
<span class="token comment"># - compatible property override enabled</span>

<span class="token comment"># This is a build configuration for a full-featured build of the</span>
<span class="token comment"># Open-Source part of the tree. It&apos;s geared toward a US-centric</span>
<span class="token comment"># build quite specifically for the emulator, and might not be</span>
<span class="token comment"># entirely appropriate to inherit from for on-device configurations.</span>

<span class="token comment"># GSI for system/product</span>
<span class="token variable"><span class="token variable">$(</span>call inherit-product, <span class="token punctuation">$(</span>SRC_TARGET_DIR<span class="token punctuation">)</span>/product/core_64_bit.mk<span class="token variable">)</span></span>
<span class="token variable"><span class="token variable">$(</span>call inherit-product, <span class="token punctuation">$(</span>SRC_TARGET_DIR<span class="token punctuation">)</span>/product/gsi_common.mk<span class="token variable">)</span></span>

<span class="token comment"># Emulator for vendor</span>
<span class="token variable"><span class="token variable">$(</span>call inherit-product-if-exists, device/generic/goldfish/x86_64-vendor.mk<span class="token variable">)</span></span>
<span class="token variable"><span class="token variable">$(</span>call inherit-product, <span class="token punctuation">$(</span>SRC_TARGET_DIR<span class="token punctuation">)</span>/product/emulator_vendor.mk<span class="token variable">)</span></span>
<span class="token variable"><span class="token variable">$(</span>call inherit-product, <span class="token punctuation">$(</span>SRC_TARGET_DIR<span class="token punctuation">)</span>/board/generic_x86_64/device.mk<span class="token variable">)</span></span>

<span class="token comment"># Enable mainline checking for excat this product name</span>
ifeq <span class="token punctuation">(</span>aosp_x86_64,<span class="token variable"><span class="token variable">$(</span>TARGET_PRODUCT<span class="token variable">)</span></span><span class="token punctuation">)</span>
PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS :<span class="token operator">=</span> relaxed
endif

PRODUCT_ARTIFACT_PATH_REQUIREMENT_WHITELIST <span class="token operator">+=</span> <span class="token punctuation">\</span>
    root/init.zygote32_64.rc <span class="token punctuation">\</span>
    root/init.zygote64_32.rc <span class="token punctuation">\</span>

<span class="token comment"># Copy different zygote settings for vendor.img to select by setting property</span>
<span class="token comment"># ro.zygote=zygote64_32 or ro.zygote=zygote32_64:</span>
<span class="token comment">#   1. 64-bit primary, 32-bit secondary OR</span>
<span class="token comment">#   2. 32-bit primary, 64-bit secondary</span>
<span class="token comment"># init.zygote64_32.rc is in the core_64_bit.mk below</span>
PRODUCT_COPY_FILES <span class="token operator">+=</span> <span class="token punctuation">\</span>
    system/core/rootdir/init.zygote32_64.rc:root/init.zygote32_64.rc

<span class="token comment"># Product &#x57FA;&#x672C;&#x4FE1;&#x606F;</span>
PRODUCT_NAME :<span class="token operator">=</span> aosp_x86_64
PRODUCT_DEVICE :<span class="token operator">=</span> generic_x86_64
PRODUCT_BRAND :<span class="token operator">=</span> Android
PRODUCT_MODEL :<span class="token operator">=</span> AOSP on x86_64
</pre><p><strong>inherit-product</strong> &#x51FD;&#x6570;&#x8868;&#x793A;&#x7EE7;&#x627F;&#x53E6;&#x5916;&#x4E00;&#x4E2A;&#x6587;&#x4EF6;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token variable"><span class="token variable">$(</span>call inherit-product, <span class="token punctuation">$(</span>SRC_TARGET_DIR<span class="token punctuation">)</span>/product/emulator_vendor.mk<span class="token variable">)</span></span>
<span class="token variable"><span class="token variable">$(</span>call inherit-product-if-exists, device/generic/goldfish/x86_64-vendor.mk<span class="token variable">)</span></span>
</pre><p>&#x5728; Makefile &#x4E2D;&#x53EF;&#x4F7F;&#x7528; <strong>&#x201C;-include&#x201D;</strong> &#x6765;&#x4EE3;&#x66FF; &#x201C;include&#x201D;&#xFF0C;&#x6765;&#x5FFD;&#x7565;&#x7531;&#x4E8E;&#x5305;&#x542B;&#x6587;&#x4EF6;&#x4E0D;&#x5B58;&#x5728;&#x6216;&#x8005;&#x65E0;&#x6CD5;&#x521B;&#x5EFA;&#x65F6;&#x7684;&#x9519;&#x8BEF;&#x63D0;&#x793A;&#xFF08;&#x201C;-&#x201D;&#x7684;&#x610F;&#x601D;&#x662F;&#x544A;&#x8BC9;make&#xFF0C;&#x5FFD;&#x7565;&#x6B64;&#x64CD;&#x4F5C;&#x7684;&#x9519;&#x8BEF;&#x3002;make&#x7EE7;&#x7EED;&#x6267;&#x884C;&#xFF09;,&#x5982;&#x679C;&#x4E0D;&#x52A0;-,&#x5F53; include &#x7684;&#x6587;&#x4EF6;&#x51FA;&#x9519;&#x6216;&#x8005;&#x4E0D;&#x5B58;&#x5728;&#x7684;&#x65F6;&#x5019;&#xFF0C; make &#x4F1A;&#x62A5;&#x9519;&#x5E76;&#x9000;&#x51FA;&#x3002;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">-include <span class="token variable"><span class="token variable">$(</span>TARGET_DEVICE_DIR<span class="token variable">)</span></span>/AndroidBoard.mk
</pre><p><strong>include &#x548C; inherit-product &#x7684;&#x533A;&#x522B;</strong>&#xFF1A;</p>
<ul>
<li>&#x5047;&#x8BBE; <code>PRODUCT_VAR := a</code> &#x5728; <a href="http://A.mk">A.mk</a> &#x4E2D;, <code>PRODUCT_VAR := b</code> &#x5728; <a href="http://B.mk">B.mk</a> &#x4E2D;&#x3002;</li>
<li>&#x5982;&#x679C;&#x4F60;&#x5728; <a href="http://A.mk">A.mk</a> &#x4E2D; include <a href="http://B.mk">B.mk</a>&#xFF0C;&#x4F60;&#x6700;&#x7EC8;&#x4F1A;&#x5F97;&#x5230; <code>PRODUCT_VAR := b</code>&#x3002;</li>
<li>&#x4F46;&#x662F;&#x5982;&#x679C;&#x4F60;&#x5728; <a href="http://A.mk">A.mk</a> inherit-product <a href="http://B.mk">B.mk</a>&#xFF0C;&#x4F60;&#x4F1A;&#x5F97;&#x5230; <code>PRODUCT_VAR := a b</code>&#x3002;&#x5E76; inherit-product &#x786E;&#x4FDD;&#x60A8;&#x4E0D;&#x4F1A;&#x4E24;&#x6B21;&#x5305;&#x542B;&#x540C;&#x4E00;&#x4E2A; makefile &#x3002;</li>
</ul>
<p><strong>Product &#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4E2D;&#x6D89;&#x53CA;&#x7684;&#x53D8;&#x91CF;</strong>&#x53EF;&#x5206;&#x4E3A;&#x4E00;&#x4E0B;&#x51E0;&#x7C7B;&#xFF1A;</p>
<ul>
<li>&#x901A;&#x7528;&#x53D8;&#x91CF;</li>
<li>&#x8DEF;&#x5F84;&#x53D8;&#x91CF;</li>
<li>&#x81EA;&#x5B9A;&#x4E49;&#x53D8;&#x91CF;</li>
<li>&#x529F;&#x80FD;&#x53D8;&#x91CF;</li>
</ul>
<p><strong>&#x901A;&#x7528;&#x53D8;&#x91CF;</strong></p>
<pre data-role="codeBlock" data-info="makefile" class="language-makefile">PRODUCT_BRAND <span class="token operator">:=</span> Android

PRODUCT_NAME <span class="token operator">:=</span> sdk_phone_x86_64

PRODUCT_DEVICE <span class="token operator">:=</span> generic_x86_64

PRODUCT_MODEL <span class="token operator">:=</span> Android SDK built for x86_64
</pre><p>&#x5E38;&#x7528;&#x7684;<strong>&#x8DEF;&#x5F84;&#x53D8;&#x91CF;</strong></p>
<ul>
<li>SRC_TARGET_DIR &#x5176;&#x503C;&#x4E3A; build/target</li>
<li>LOCAL_DIR &#x4EE3;&#x8868;&#x5F53;&#x524D;&#x76EE;&#x5F55;</li>
</ul>
<p><strong>&#x81EA;&#x5B9A;&#x4E49;&#x53D8;&#x91CF;</strong>&#xFF0C;&#x8868;&#x793A;&#x8BE5;&#x53D8;&#x91CF;&#x5982;&#x4F55;&#x4F7F;&#x7528;&#xFF0C; &#x53D6;&#x51B3;&#x4E8E;&#x81EA;&#x5DF1;&#xFF0C;&#x5982;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="makefile" class="language-makefile">BOARD_DDR_VAR_ENABLED <span class="token operator">:=</span> true
</pre><p><strong>&#x529F;&#x80FD;&#x53D8;&#x91CF;</strong>&#xFF1A;&#x8868;&#x793A;&#x6539;&#x53D8;&#x91CF;&#x6709;&#x7279;&#x6B8A;&#x529F;&#x80FD;</p>
<ul>
<li>PRODUCT_COPY_FILES&#xFF1A; &#x7528;&#x4E8E;&#x5B8C;&#x6210;&#x62F7;&#x8D1D;&#xFF0C;&#x53EF;&#x4EE5;&#x5C06;&#x6E90;&#x7801;&#x4E2D;&#x7684;&#x6587;&#x4EF6;&#x62F7;&#x8D1D;&#x5230;&#x7F16;&#x8BD1;&#x597D;&#x7684;&#x5206;&#x533A;&#x6587;&#x4EF6;&#x4E2D;</li>
</ul>
<pre data-role="codeBlock" data-info="makefile" class="language-makefile">PRODUCT_COPY_FILES <span class="token operator">+=</span> vendor/rockchip/common/phone/etc/spn-conf.xml<span class="token punctuation">:</span>system/etc/spn-conf.xml
</pre><ul>
<li>PRODUCT_PROPERTY_OVERRIDES&#xFF1A; &#x7528;&#x4E8E;&#x8BBE;&#x7F6E;&#x7CFB;&#x7EDF;&#x5C5E;&#x6027;(&#x8986;&#x76D6;)</li>
</ul>
<pre data-role="codeBlock" data-info="makefile" class="language-makefile">PRODUCT_PROPERTY_OVERRIDES <span class="token operator">+=</span> \
    ro.product.version <span class="token operator">=</span> 1.0.0 \
</pre><h3 class="mume-header" id="3-%E6%B7%BB%E5%8A%A0%E8%87%AA%E5%B7%B1%E7%9A%84-product">3. &#x6DFB;&#x52A0;&#x81EA;&#x5DF1;&#x7684; Product</h3>

<p>&#x8FD9;&#x91CC;&#x5047;&#x8BBE;&#x6211;&#x4EEC;&#x7684;&#x516C;&#x53F8;&#x540D;&#x53EB;&#x679C;&#x51BB;&#xFF08;Jelly&#xFF09;&#xFF0C;&#x6211;&#x4EEC;&#x51C6;&#x5907;&#x5F00;&#x53D1;&#x4E00;&#x6B3E;&#x5BF9;&#x6807;&#x82F9;&#x679C; 14 &#x7684;&#x624B;&#x673A;&#xFF0C;&#x53D6;&#x540D;&#x53EB; &#x5927;&#x7C73;14&#xFF08;Rice14&#xFF09;&#x3002;</p>
<p>&#x63A5;&#x4E0B;&#x6765;&#x6211;&#x4EEC;&#x5728;&#x6E90;&#x7801;&#x4E2D;&#x6DFB;&#x52A0;&#x6211;&#x4EEC;&#x81EA;&#x5DF1;&#x7684;&#x4EA7;&#x54C1;&#xFF08;Product&#xFF09;</p>
<p>&#x5728; device &#x76EE;&#x5F55;&#x4E0B;&#x6DFB;&#x52A0;&#x5982;&#x4E0B;&#x7684;&#x76EE;&#x5F55;&#x4E0E;&#x6587;&#x4EF6;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">Jelly/
&#x2514;&#x2500;&#x2500; Rice14
    &#x251C;&#x2500;&#x2500; AndroidProducts.mk
    &#x251C;&#x2500;&#x2500; BoardConfig.mk
    &#x2514;&#x2500;&#x2500; Rice14.mk
</pre><p><a href="http://BoardConfig.mk">BoardConfig.mk</a> &#x5305;&#x542B;&#x4E86;&#x786C;&#x4EF6;&#x82AF;&#x7247;&#x67B6;&#x6784;&#x914D;&#x7F6E;&#xFF0C;&#x5206;&#x533A;&#x5927;&#x5C0F;&#x914D;&#x7F6E;&#x7B49;&#x4FE1;&#x606F;&#x8FD9;&#x91CC;&#x6211;&#x4EEC;&#x76F4;&#x63A5;&#x4F7F;&#x7528; aosp_x86_64 &#x7684; <a href="http://BoardConfig.mk">BoardConfig.mk</a> &#x5C31;&#x884C;&#x3002;<a href="http://BoardConfig.mk">BoardConfig.mk</a> &#x62F7;&#x8D1D;&#x81EA; build/target/board/generic_x86_64/BoardConfig.mk</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token comment"># x86_64 emulator specific definitions</span>
TARGET_CPU_ABI :<span class="token operator">=</span> x86_64
TARGET_ARCH :<span class="token operator">=</span> x86_64
TARGET_ARCH_VARIANT :<span class="token operator">=</span> x86_64

TARGET_2ND_CPU_ABI :<span class="token operator">=</span> x86
TARGET_2ND_ARCH :<span class="token operator">=</span> x86
TARGET_2ND_ARCH_VARIANT :<span class="token operator">=</span> x86_64

TARGET_PRELINK_MODULE :<span class="token operator">=</span> <span class="token boolean">false</span>
include build/make/target/board/BoardConfigGsiCommon.mk
include build/make/target/board/BoardConfigEmuCommon.mk

BOARD_USERDATAIMAGE_PARTITION_SIZE :<span class="token operator">=</span> <span class="token number">576716800</span>

BOARD_SEPOLICY_DIRS <span class="token operator">+=</span> device/generic/goldfish/sepolicy/x86

<span class="token comment"># Wifi.</span>
BOARD_WLAN_DEVICE           :<span class="token operator">=</span> emulator
BOARD_HOSTAPD_DRIVER        :<span class="token operator">=</span> NL80211
BOARD_WPA_SUPPLICANT_DRIVER :<span class="token operator">=</span> NL80211
BOARD_HOSTAPD_PRIVATE_LIB   :<span class="token operator">=</span> lib_driver_cmd_simulated
BOARD_WPA_SUPPLICANT_PRIVATE_LIB :<span class="token operator">=</span> lib_driver_cmd_simulated
WPA_SUPPLICANT_VERSION      :<span class="token operator">=</span> VER_0_8_X
WIFI_DRIVER_FW_PATH_PARAM   :<span class="token operator">=</span> <span class="token string">&quot;/dev/null&quot;</span>
WIFI_DRIVER_FW_PATH_STA     :<span class="token operator">=</span> <span class="token string">&quot;/dev/null&quot;</span>
WIFI_DRIVER_FW_PATH_AP      :<span class="token operator">=</span> <span class="token string">&quot;/dev/null&quot;</span>
</pre><p><a href="http://Rice14.mk">Rice14.mk</a> &#x62F7;&#x8D1D;&#x81EA; build/target/product/aosp_x86_64.mk</p>
<p>&#x5176;&#x4E2D;&#x7684; if &#x8BED;&#x53E5;&#x9700;&#x8981;&#x6CE8;&#x91CA;&#x6389;&#xFF0C;&#x540C;&#x65F6;&#x9700;&#x8981;&#x4FEE;&#x6539;&#x6700;&#x540E;&#x56DB;&#x884C;</p>
<pre data-role="codeBlock" data-info="makefile" class="language-makefile">PRODUCT_USE_DYNAMIC_PARTITIONS <span class="token operator">:=</span> true

<span class="token comment"># The system image of aosp_x86_64-userdebug is a GSI for the devices with:</span>
<span class="token comment"># - x86 64 bits user space</span>
<span class="token comment"># - 64 bits binder interface</span>
<span class="token comment"># - system-as-root</span>
<span class="token comment"># - VNDK enforcement</span>
<span class="token comment"># - compatible property override enabled</span>

<span class="token comment"># This is a build configuration for a full-featured build of the</span>
<span class="token comment"># Open-Source part of the tree. It&apos;s geared toward a US-centric</span>
<span class="token comment"># build quite specifically for the emulator, and might not be</span>
<span class="token comment"># entirely appropriate to inherit from for on-device configurations.</span>

<span class="token comment"># GSI for system/product</span>
<span class="token variable">$</span><span class="token punctuation">(</span><span class="token keyword keyword-call">call</span> inherit-product, <span class="token variable">$</span><span class="token punctuation">(</span>SRC_TARGET_DIR<span class="token punctuation">)</span>/product/core_64_bit.mk<span class="token punctuation">)</span>
<span class="token variable">$</span><span class="token punctuation">(</span><span class="token keyword keyword-call">call</span> inherit-product, <span class="token variable">$</span><span class="token punctuation">(</span>SRC_TARGET_DIR<span class="token punctuation">)</span>/product/gsi_common.mk<span class="token punctuation">)</span>

<span class="token comment"># Emulator for vendor</span>
<span class="token variable">$</span><span class="token punctuation">(</span><span class="token keyword keyword-call">call</span> inherit-product-if-exists, device/generic/goldfish/x86_64-vendor.mk<span class="token punctuation">)</span>
<span class="token variable">$</span><span class="token punctuation">(</span><span class="token keyword keyword-call">call</span> inherit-product, <span class="token variable">$</span><span class="token punctuation">(</span>SRC_TARGET_DIR<span class="token punctuation">)</span>/product/emulator_vendor.mk<span class="token punctuation">)</span>
<span class="token variable">$</span><span class="token punctuation">(</span><span class="token keyword keyword-call">call</span> inherit-product, <span class="token variable">$</span><span class="token punctuation">(</span>SRC_TARGET_DIR<span class="token punctuation">)</span>/board/generic_x86_64/device.mk<span class="token punctuation">)</span>

<span class="token comment"># Enable mainline checking for excat this product name</span>
<span class="token comment">#ifeq (aosp_x86_64,$(TARGET_PRODUCT))</span>
PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS <span class="token operator">:=</span> relaxed
<span class="token comment">#endif</span>

PRODUCT_ARTIFACT_PATH_REQUIREMENT_WHITELIST <span class="token operator">+=</span> \
    root/init.zygote32_64.rc \
    root/init.zygote64_32.rc \

<span class="token comment"># Copy different zygote settings for vendor.img to select by setting property</span>
<span class="token comment"># ro.zygote=zygote64_32 or ro.zygote=zygote32_64:</span>
<span class="token comment">#   1. 64-bit primary, 32-bit secondary OR</span>
<span class="token comment">#   2. 32-bit primary, 64-bit secondary</span>
<span class="token comment"># init.zygote64_32.rc is in the core_64_bit.mk below</span>
PRODUCT_COPY_FILES <span class="token operator">+=</span> \
<span class="token symbol">    system/core/rootdir/init.zygote32_64.rc</span><span class="token punctuation">:</span>root/init.zygote32_64.rc

<span class="token comment"># Overrides</span>
PRODUCT_BRAND <span class="token operator">:=</span> Jelly
PRODUCT_NAME <span class="token operator">:=</span> Rice14
PRODUCT_DEVICE <span class="token operator">:=</span> Rice14
PRODUCT_MODEL <span class="token operator">:=</span> Android SDK built for x86_64 Rice14
</pre><p><a href="http://AndroidProducts.mk">AndroidProducts.mk</a> &#x5185;&#x5BB9;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="makefile" class="language-makefile">PRODUCT_MAKEFILES <span class="token operator">:=</span> \
    <span class="token variable">$</span><span class="token punctuation">(</span>LOCAL_DIR<span class="token punctuation">)</span>/Rice14.mk

COMMON_LUNCH_CHOICES <span class="token operator">:=</span> \
    Rice14-eng \
    Rice14-userdebug \
    Rice14-user \
</pre><p>&#x6700;&#x540E;&#x9A8C;&#x8BC1;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token builtin class-name">source</span> build/envsetup.sh
lunch Rice14-eng
<span class="token function">make</span> -j16
emulator
</pre><p>&#x4EE5;&#x4E0A;&#x793A;&#x4F8B;&#x7ED9;&#x51FA;&#x4E86;&#x6700;&#x7B80;&#x5355;&#x7684;&#x6A21;&#x62DF;&#x5668; Product &#x7684;&#x6DFB;&#x52A0;&#xFF0C;&#x4E3B;&#x8981;&#x662F;&#x7528;&#x4E8E;&#x6211;&#x4EEC;&#x7684;&#x5B66;&#x4E60;&#x3002;</p>
<h2 class="mume-header" id="%E7%AC%AC%E5%9B%9B%E7%AB%A0-%E6%B7%BB%E5%8A%A0%E5%8F%AF%E6%89%A7%E8%A1%8C%E7%A8%8B%E5%BA%8F">&#x7B2C;&#x56DB;&#x7AE0; &#x6DFB;&#x52A0;&#x53EF;&#x6267;&#x884C;&#x7A0B;&#x5E8F;</h2>

<p>AOSP &#x6DFB;&#x52A0;&#x7684;&#x53EF;&#x6267;&#x884C;&#x7A0B;&#x5E8F;&#xFF0C;&#x53EF;&#x4EE5;&#x5206;&#x4E3A;&#x4E24;&#x7C7B;&#xFF1A;</p>
<ul>
<li>C/C++ &#x53EF;&#x6267;&#x884C;&#x7A0B;&#x5E8F;</li>
<li>Java &#x53EF;&#x6267;&#x884C;&#x7A0B;&#x5E8F;</li>
</ul>
<p>&#x5728;&#x4E86;&#x89E3;&#x5982;&#x4F55;&#x7ED9; AOSP &#x6DFB;&#x52A0;&#x53EF;&#x6267;&#x884C;&#x7A0B;&#x5E8F;&#x524D;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x4E86;&#x89E3;&#x4E00;&#x4E0B;ARM + Android &#x884C;&#x4E1A;&#x6D41;&#x7A0B;&#x4E0E; Android &#x5E38;&#x7528;&#x7684;&#x56DB;&#x4E2A;&#x5206;&#x533A;&#xFF1A;</p>
<ul>
<li>System &#x5206;&#x533A;</li>
<li>Vender &#x5206;&#x533A;</li>
<li>Odm &#x5206;&#x533A;</li>
<li>Product &#x5206;&#x533A;</li>
</ul>
<h3 class="mume-header" id="1-arm--android-%E8%A1%8C%E4%B8%9A%E6%B5%81%E7%A8%8B%E4%B8%8E-android-%E5%88%86%E5%8C%BA">1. ARM + Android &#x884C;&#x4E1A;&#x6D41;&#x7A0B;&#x4E0E; Android &#x5206;&#x533A;</h3>

<p>ARM + Android &#x8FD9;&#x4E2A;&#x884C;&#x4E1A;&#xFF0C;&#x4E00;&#x4E2A;&#x7B80;&#x5316;&#x7684;&#x666E;&#x904D;&#x6D41;&#x7A0B;&#xFF1A;</p>
<ol>
<li>Google &#x5F00;&#x53D1;&#x8FED;&#x4EE3; AOSP + Kernel</li>
<li>&#x82AF;&#x7247;&#x5382;&#x5546;&#xFF0C;&#x9488;&#x5BF9;&#x81EA;&#x5DF1;&#x7684;&#x82AF;&#x7247;&#x7279;&#x70B9;&#xFF0C;&#x79FB;&#x690D; AOSP &#x548C; Kernel&#xFF0C;&#x4F7F;&#x5176;&#x53EF;&#x4EE5;&#x5728;&#x81EA;&#x5DF1;&#x7684;&#x82AF;&#x7247;&#x4E0A;&#x8DD1;&#x8D77;&#x6765;&#x3002;</li>
<li>&#x65B9;&#x6848;&#x5382;&#x5546;&#xFF08;&#x5F88;&#x591A;&#x82AF;&#x7247;&#x5382;&#x5546;&#x4E5F;&#x626E;&#x6F14;&#x4E86;&#x65B9;&#x6848;&#x5382;&#x5546;&#x7684;&#x89D2;&#x8272;&#xFF09;&#xFF0C;&#x8BBE;&#x8BA1;&#x7535;&#x8DEF;&#x677F;&#xFF0C;&#x7ED9;&#x82AF;&#x7247;&#x6DFB;&#x52A0;&#x5916;&#x8BBE;&#xFF0C;&#x5728;&#x82AF;&#x7247;&#x5382;&#x5546;&#x6E90;&#x7801;&#x57FA;&#x7840;&#x4E0A;&#x5F00;&#x53D1;&#x5916;&#x8BBE;&#x76F8;&#x5173;&#x8F6F;&#x4EF6;&#xFF0C;&#x4E3B;&#x8981;&#x662F;&#x9A71;&#x52A8;&#x548C; hal&#xFF0C;&#x6539;&#x8FDB;&#x6027;&#x80FD;&#x548C;&#x7A33;&#x5B9A;&#x6027;&#x3002;</li>
<li>&#x4EA7;&#x54C1;&#x5382;&#x5546;&#xFF0C;&#x4E3B;&#x8981;&#x662F;&#x7CFB;&#x7EDF;&#x8F6F;&#x4EF6;&#x5F00;&#x53D1;&#xFF0C;UI &#x5B9A;&#x5236;&#x4EE5;&#x53CA;&#x786C;&#x4EF6;&#x4E0A;&#x7684;&#x5B9A;&#x5236;(&#x6DFB;&#x52A0;&#x81EA;&#x5DF1;&#x7684;&#x5916;&#x8BBE;)&#xFF0C;&#x6539;&#x8FDB;&#x6027;&#x80FD;&#x548C;&#x7A33;&#x5B9A;&#x6027;.</li>
</ol>
<p>Google &#x5F00;&#x53D1;&#x7684;&#x901A;&#x7528; Android &#x7CFB;&#x7EDF;&#x7EC4;&#x4EF6;&#x7F16;&#x8BD1;&#x540E;&#x4F1A;&#x88AB;&#x5B58;&#x653E;&#x5230; System &#x5206;&#x533A;&#xFF0C;&#x539F;&#x5219;&#x4E0A;&#x4E0D;&#x540C;&#x5382;&#x5546;&#x3001;&#x4E0D;&#x540C;&#x578B;&#x53F7;&#x7684;&#x8BBE;&#x5907;&#x90FD;&#x901A;&#x7528;&#x3002;</p>
<p>&#x82AF;&#x7247;&#x5382;&#x5546;&#x548C;&#x65B9;&#x6848;&#x5382;&#x5546;&#x9488;&#x5BF9;&#x786C;&#x4EF6;&#x76F8;&#x5173;&#x7684;&#x5E73;&#x53F0;&#x901A;&#x7528;&#x7684;&#x53EF;&#x6267;&#x884C;&#x7A0B;&#x5E8F;&#x3001;&#x5E93;&#x3001;&#x7CFB;&#x7EDF;&#x670D;&#x52A1;&#x548C; app &#x7B49;&#x4E00;&#x822C;&#x653E;&#x5230; Vender &#x5206;&#x533A;&#x3002;&#xFF08;&#x5F00;&#x53D1;&#x7684;&#x9A71;&#x52A8;&#x7A0B;&#x5E8F;&#x662F;&#x653E;&#x5728; boot &#x5206;&#x533A;&#x7684; kernel &#x90E8;&#x5206;&#xFF09;</p>
<p>&#x5230;&#x4E86;&#x4EA7;&#x54C1;&#x5382;&#x5546;&#x8FD9;&#x91CC;&#xFF0C;&#x60C5;&#x51B5;&#x7A0D;&#x5FAE;&#x590D;&#x6742;&#x4E00;&#x70B9;&#xFF0C;&#x901A;&#x5E38;&#x9488;&#x5BF9;&#x540C;&#x4E00;&#x5957;&#x8F6F;&#x786C;&#x4EF6;&#x5E73;&#x53F0;&#xFF0C;&#x53EF;&#x80FD;&#x4F1A;&#x5F00;&#x53D1;&#x591A;&#x4E2A;&#x4EA7;&#x54C1;&#x3002;&#x6BD4;&#x5982;&#xFF1A;&#x5C0F;&#x7C73; 12s&#xFF0C;&#x5C0F;&#x7C73;12s pro&#xFF0C;&#x5C0F;&#x7C73;12s ultra &#x5747;&#x6E90;&#x4E8E;&#x9A81;&#x9F99;8+&#x5E73;&#x53F0;&#x3002;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230223201246.png" alt></p>
<p>&#x6BCF;&#x4E00;&#x4E2A;&#x4EA7;&#x54C1;&#xFF0C;&#x6211;&#x4EEC;&#x79F0;&#x4E4B;&#x4E3A;&#x4E00;&#x4E2A; Variant&#xFF08;&#x53D8;&#x4F53;&#xFF09;&#x3002;</p>
<p>&#x901A;&#x5E38;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x505A;&#x4EA7;&#x54C1;&#x7684;&#x5382;&#x5546;&#x5728;&#x540C;&#x4E00;&#x4E2A;&#x786C;&#x4EF6;&#x5E73;&#x53F0;&#x4E0A;&#x9488;&#x5BF9;&#x4E0D;&#x540C;&#x7684;&#x4EA7;&#x54C1;&#x4F1A;&#x4ECE;&#x786C;&#x4EF6;&#x548C;&#x8F6F;&#x4EF6;&#x4E24;&#x4E2A;&#x7EF4;&#x5EA6;&#x6765;&#x505A;&#x5B9A;&#x5236;&#x3002;</p>
<p>&#x786C;&#x4EF6;&#x4E0A;&#xFF0C;&#x4EA7;&#x54C1; A &#x53EF;&#x80FD;&#x7528;&#x7684;&#x662F;&#x4EAC;&#x4E1C;&#x65B9;&#x7684;&#x5C4F;&#xFF0C;&#x4EA7;&#x54C1; B &#x53EF;&#x80FD;&#x7528;&#x7684;&#x662F;&#x4E09;&#x661F;&#x7684;&#x5C4F;&#xFF1B;&#x5DEE;&#x5F02;&#x786C;&#x4EF6;&#x76F8;&#x5173;&#x7684;&#x8F6F;&#x4EF6;&#x90E8;&#x5206;&#x90FD;&#x4F1A;&#x653E;&#x5728; Odm &#x5206;&#x533A;&#x3002;&#x8FD9;&#x6837;&#xFF0C;&#x4EA7;&#x54C1; A &#x548C;&#x4EA7;&#x54C1; B &#x4E4B;&#x95F4; Odm &#x4EE5;&#x5916;&#x7684;&#x5206;&#x533A;&#x90FD;&#x662F;&#x4E00;&#x6837;&#x7684;&#xFF0C;&#x4FBF;&#x4E8E;&#x7EDF;&#x4E00;&#x7EF4;&#x62A4;&#x4E0E;&#x5347;&#x7EA7;&#x3002;(&#x786C;&#x4EF6;&#x76F8;&#x5173;&#x7684;&#x8F6F;&#x4EF6;&#x5171;&#x7528;&#x90E8;&#x5206;&#x653E;&#x5728; vendor &#x5206;&#x533A;)</p>
<p>&#x8F6F;&#x4EF6;&#x4E0A;&#xFF0C;&#x4EA7;&#x54C1; A &#x53EF;&#x80FD;&#x662F;&#x5E26;&#x5E7F;&#x544A;&#x7684;&#x7248;&#x672C;&#xFF0C;&#x4EA7;&#x54C1; B &#x53EF;&#x80FD;&#x662F;&#x4E0D;&#x5E26;&#x5E7F;&#x544A;&#x7684;&#x7248;&#x672C;&#x3002;&#x8FD9;&#x4E9B;&#x6709;&#x5DEE;&#x5F02;&#x7684;&#x8F6F;&#x4EF6;&#x90E8;&#x5206;&#x90FD;&#x653E;&#x5728; Product &#x5206;&#x533A;&#xFF0C;&#x8FD9;&#x6837;&#x4EA7;&#x54C1; A &#x548C;&#x4EA7;&#x54C1; B &#x4E4B;&#x95F4; Product &#x4EE5;&#x5916;&#x7684;&#x5206;&#x533A;&#x90FD;&#x662F;&#x4E00;&#x6837;&#x7684;&#xFF0C;&#x4FBF;&#x4E8E;&#x7EDF;&#x4E00;&#x7EF4;&#x62A4;&#x4E0E;&#x5347;&#x7EA7;&#x3002;(&#x8F6F;&#x4EF6;&#x5171;&#x7528;&#x90E8;&#x5206;&#x90FD;&#x653E;&#x5728; System&#x5206;&#x533A;)</p>
<p>&#x603B;&#x7ED3;&#x4E00;&#x4E0B;&#xFF0C;&#x4E0D;&#x540C;&#x4EA7;&#x54C1;&#x4E4B;&#x95F4;&#x516C;&#x5171;&#x7684;&#x90E8;&#x5206;&#x653E;&#x5728; System &#x548C; Vender &#x5206;&#x533A;&#xFF0C;&#x5DEE;&#x5F02;&#x7684;&#x90E8;&#x5206;&#x653E;&#x5728; Odm &#x548C; Product &#x5206;&#x533A;&#x3002;</p>
<h3 class="mume-header" id="2-%E5%8A%A8%E6%89%8B%E5%9C%A8%E7%B3%BB%E7%BB%9F%E6%BA%90%E7%A0%81%E4%B8%AD%E6%B7%BB%E5%8A%A0%E4%B8%80%E4%B8%AA-cc-%E5%8F%AF%E6%89%A7%E8%A1%8C%E7%A8%8B%E5%BA%8F">2. &#x52A8;&#x624B;&#x5728;&#x7CFB;&#x7EDF;&#x6E90;&#x7801;&#x4E2D;&#x6DFB;&#x52A0;&#x4E00;&#x4E2A; C/C++ &#x53EF;&#x6267;&#x884C;&#x7A0B;&#x5E8F;</h3>

<h4 class="mume-header" id="21-%E6%BA%90%E7%A0%81%E6%B7%BB%E5%8A%A0">2.1 &#x6E90;&#x7801;&#x6DFB;&#x52A0;</h4>

<p>&#x6211;&#x4EEC;&#x5148;&#x770B;&#x770B;&#x5982;&#x4F55;&#x4EE5;&#x6E90;&#x7801;&#x7684;&#x65B9;&#x5F0F;&#x6765;&#x6DFB;&#x52A0;&#x4E00;&#x4E2A;&#x53EF;&#x6267;&#x884C;&#x7A0B;&#x5E8F;&#x3002;</p>
<p>&#x5728; <code>device/Jelly/Rice14</code> &#x76EE;&#x5F55;&#x4E0B;&#x521B;&#x5EFA;&#x5982;&#x4E0B;&#x7684;&#x6587;&#x4EF6;&#x7ED3;&#x6784;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">hello
&#x251C;&#x2500;&#x2500; Android.bp
&#x2514;&#x2500;&#x2500; hello.cpp
</pre><p>&#x5176;&#x4E2D; hello.cpp &#x7684;&#x5185;&#x5BB9;&#x5982;&#x4E0B;</p>
<pre data-role="codeBlock" data-info="c++" class="language-cpp"><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;cstdio&gt;</span></span>

<span class="token keyword keyword-int">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">&quot;Hello Android\n&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword keyword-return">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</pre><p>Android.bp&#x662F;&#x7A0B;&#x5E8F;&#x7684;&#x7F16;&#x8BD1;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#xFF0C;&#x4F5C;&#x7528;&#x7C7B;&#x4F3C;&#x4E8E; App &#x5F00;&#x53D1;&#x4E2D;&#x7684; gradle.build &#x6587;&#x4EF6;&#xFF0C;&#x5176;&#x683C;&#x5F0F;&#x4E3A; json&#x3002;Android.bp &#x7684;&#x5185;&#x5BB9;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="json" class="language-json">cc_binary <span class="token punctuation">{</span>                 <span class="token comment">//&#x6A21;&#x5757;&#x7C7B;&#x578B;&#x4E3A;&#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;</span>
    name<span class="token operator">:</span> <span class="token string">&quot;hello&quot;</span><span class="token punctuation">,</span>          <span class="token comment">//&#x6A21;&#x5757;&#x540D;hello</span>
    srcs<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;hello.cpp&quot;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>    <span class="token comment">//&#x6E90;&#x6587;&#x4EF6;&#x5217;&#x8868;</span>
    cflags<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;-Werror&quot;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>    <span class="token comment">//&#x6DFB;&#x52A0;&#x7F16;&#x8BD1;&#x9009;&#x9879;</span>
<span class="token punctuation">}</span>
</pre><p>&#x5728; <code>device/Jelly/Rice14/Rice14.mk</code> &#x4E2D;&#x6DFB;&#x52A0;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">PRODUCT_PACKAGES <span class="token operator">+=</span> hello
</pre><p>&#x63A5;&#x4E0B;&#x6765;&#x7F16;&#x8BD1;&#x7CFB;&#x7EDF;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token builtin class-name">source</span> build/envsetup.sh
lunch Rice14-eng
<span class="token function">make</span> -j16
</pre><p>&#x4F60;&#x4F1A;&#x53D1;&#x73B0;&#x62A5;&#x9519;&#x4E86;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">Offending entries:
system/bin/helloworld
build/make/core/main.mk:1414: error: Build failed.
</pre><p>&#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x6211;&#x4EEC;&#x7684;&#x6A21;&#x5757;&#x4F1A;&#x88AB;&#x5B89;&#x88C5;&#x5230; System &#x5206;&#x533A;&#xFF0C;&#x7F16;&#x8BD1;&#x7CFB;&#x7EDF;&#x9650;&#x5236;&#x4E86;&#x6211;&#x4EEC;&#x5728; System &#x5206;&#x533A;&#x6DFB;&#x52A0;&#x4E1C;&#x897F;&#xFF0C;&#x7406;&#x8BBA;&#x4E0A;&#x6765;&#x8BF4;&#xFF0C; System &#x5206;&#x533A;&#x5E94;&#x8BE5;&#x53EA;&#x80FD;&#x7531; Google &#x6765;&#x6DFB;&#x52A0;&#x548C;&#x4FEE;&#x6539;&#x5185;&#x5BB9;&#x3002;</p>
<p>&#x8FD9;&#x79CD;&#x9519;&#x8BEF;&#x4E00;&#x822C;&#x90FD;&#x80FD;&#x641C;&#x5230;&#x89E3;&#x51B3;&#x529E;&#x6CD5;&#xFF0C;&#x901A;&#x8FC7;&#x641C;&#x7D22;&#x5F15;&#x64CE;&#x6211;&#x627E;&#x5230;&#x4E86; Android <a href="https://groups.google.com/g/android-building/c/KE-Sfavd4Ds/m/GDqP5XGMAwAJ">&#x5B98;&#x65B9;&#x8BBA;&#x575B;&#x7684;&#x56DE;&#x590D;</a></p>
<p>&#x5927;&#x6982;&#x610F;&#x601D;&#x8BF4;&#xFF0C;&#x6211;&#x4EEC;&#x5F97;&#x6539;&#x4E0B;&#x7F16;&#x8BD1;&#x7CFB;&#x7EDF;&#x7684;&#x67D0;&#x4E2A;&#x6587;&#x4EF6;&#xFF0C;&#x5177;&#x4F53;&#x548B;&#x6539;&#x4ED6;&#x4E5F;&#x6CA1;&#x8BF4;&#xFF0C;&#x8981;&#x4E48;&#x5C31;&#x5199;&#x5230; product &#x5206;&#x533A;&#x3002;</p>
<p>&#x5982;&#x679C;&#x73B0;&#x5728;&#x7684;&#x60C5;&#x51B5;&#x662F;&#xFF0C;&#x6211;&#x5C31;&#x60F3;&#x628A;&#x5B83;&#x9884;&#x5236;&#x5230; system &#x5206;&#x533A;&#xFF0C;&#x548B;&#x6574;&#xFF1F;&#x90A3;&#x6211;&#x4EEC;&#x5C31;&#x770B;&#x770B; google &#x81EA;&#x5DF1;&#x662F;&#x600E;&#x4E48;&#x5E72;&#x7684;&#x3002;</p>
<p>&#x9996;&#x5148;&#x601D;&#x8DEF;&#x68B3;&#x7406;&#x6E05;&#x695A;&#xFF1A;</p>
<ul>
<li>&#x627E;&#x4E2A;&#x539F;&#x751F;&#x7CFB;&#x7EDF;&#x4E2D;&#x9884;&#x5236;&#x7684; app&#xFF0C;&#x770B;&#x4E0B;&#x5B83;&#x7684; <a href="http://Android.mk">Android.mk</a> &#x6216;&#x8005; Android.bp</li>
<li>build/target &#x4E2D;&#x641C;&#x4E00;&#x4E0B;&#x8FD9;&#x4E2A; app &#x662F;&#x600E;&#x4E48;&#x6DFB;&#x52A0;&#x7684;</li>
</ul>
<p>app &#x4E00;&#x822C;&#x5B9A;&#x4E49;&#x5728; packages/apps &#x4E2D;&#xFF0C;&#x6211;&#x770B;&#x4E0B;&#x8FD9;&#x4E2A;&#x76EE;&#x5F55;&#x4E2D;&#x7684; Messaging&#xFF0C;&#x770B;&#x4E0B;&#x5B83;&#x7684; <a href="http://Android.mk">Android.mk</a></p>
<pre data-role="codeBlock" data-info="Makefile" class="language-makefile">LOCAL_PATH<span class="token operator">:=</span> <span class="token variable">$</span><span class="token punctuation">(</span><span class="token keyword keyword-call">call</span> my-dir<span class="token punctuation">)</span>

<span class="token keyword keyword-include">include</span> <span class="token variable">$</span><span class="token punctuation">(</span>CLEAR_VARS<span class="token punctuation">)</span>

LOCAL_MODULE_TAGS <span class="token operator">:=</span> optional

LOCAL_SRC_FILES <span class="token operator">:=</span> <span class="token variable">$</span><span class="token punctuation">(</span><span class="token keyword keyword-call">call</span> all-java-files-under, src<span class="token punctuation">)</span>

LOCAL_RESOURCE_DIR <span class="token operator">:=</span> <span class="token variable">$</span><span class="token punctuation">(</span>LOCAL_PATH<span class="token punctuation">)</span>/res
LOCAL_USE_AAPT2 <span class="token operator">:=</span> true

LOCAL_STATIC_ANDROID_LIBRARIES <span class="token operator">:=</span> \
    androidx.core_core \
    androidx.media_media \
    androidx.legacy_legacy-support-core-utils \
    androidx.legacy_legacy-support-core-ui \
    androidx.fragment_fragment \
    androidx.appcompat_appcompat \
    androidx.palette_palette \
    androidx.recyclerview_recyclerview \
    androidx.legacy_legacy-support-v13 \
    colorpicker \
    libchips \
    libphotoviewer

LOCAL_STATIC_JAVA_LIBRARIES <span class="token operator">:=</span> \
    androidx.annotation_annotation \
    android-common \
    android-common-framesequence \
    com.android.vcard \
    guava \
    libphonenumber

<span class="token keyword keyword-include">include</span> <span class="token variable">$</span><span class="token punctuation">(</span>LOCAL_PATH<span class="token punctuation">)</span>/version.mk

LOCAL_AAPT_FLAGS <span class="token operator">+=</span> --version-name <span class="token string">&quot;$(version_name_package)&quot;</span>
LOCAL_AAPT_FLAGS <span class="token operator">+=</span> --version-code <span class="token variable">$</span><span class="token punctuation">(</span>version_code_package<span class="token punctuation">)</span>

<span class="token keyword keyword-ifdef">ifdef</span> TARGET_BUILD_APPS
    LOCAL_JNI_SHARED_LIBRARIES <span class="token operator">:=</span> libframesequence libgiftranscode
<span class="token keyword keyword-else">else</span>
    LOCAL_REQUIRED_MODULES<span class="token operator">:=</span> libframesequence libgiftranscode
<span class="token keyword keyword-endif">endif</span>

LOCAL_PROGUARD_ENABLED <span class="token operator">:=</span> obfuscation optimization

LOCAL_PROGUARD_FLAG_FILES <span class="token operator">:=</span> proguard.flags
<span class="token keyword keyword-ifeq">ifeq</span> <span class="token punctuation">(</span>eng,<span class="token variable">$</span><span class="token punctuation">(</span>TARGET_BUILD_VARIANT<span class="token punctuation">)</span><span class="token punctuation">)</span>
    LOCAL_PROGUARD_FLAG_FILES <span class="token operator">+=</span> proguard-test.flags
<span class="token keyword keyword-else">else</span>
    LOCAL_PROGUARD_FLAG_FILES <span class="token operator">+=</span> proguard-release.flags
<span class="token keyword keyword-endif">endif</span>

LOCAL_PACKAGE_NAME <span class="token operator">:=</span> messaging

LOCAL_CERTIFICATE <span class="token operator">:=</span> platform

LOCAL_SDK_VERSION <span class="token operator">:=</span> current

<span class="token keyword keyword-include">include</span> <span class="token variable">$</span><span class="token punctuation">(</span>BUILD_PACKAGE<span class="token punctuation">)</span>

<span class="token keyword keyword-include">include</span> <span class="token variable">$</span><span class="token punctuation">(</span><span class="token keyword keyword-call">call</span> all-makefiles-under, <span class="token variable">$</span><span class="token punctuation">(</span>LOCAL_PATH<span class="token punctuation">)</span><span class="token punctuation">)</span>
</pre><p>&#x6CA1;&#x4EC0;&#x4E48;&#x7279;&#x522B;&#x7684;&#xFF0C;&#x5BF9;&#x6211;&#x4EEC;&#x6709;&#x7528;&#x7684;&#x4FE1;&#x606F;&#x5C31;&#x662F;&#x6A21;&#x5757;&#x540D;&#x662F; messaging&#xFF0C;&#x90A3;&#x6253;&#x5305;&#x51FA;&#x6765;&#x7684; apk &#x540D;&#x5C31;&#x53EB; messaging.apk</p>
<p>&#x6211;&#x4EEC;&#x63A5;&#x7740;&#x5728; build/target &#x76EE;&#x5F55;&#x4E0B;&#x641C;&#x4E00;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token function">grep</span> -r <span class="token string">&quot;messaging.apk&quot;</span> <span class="token builtin class-name">.</span>

./product/gsi_common.mk:    system/app/messaging/messaging.apk <span class="token punctuation">\</span>
</pre><p>&#x770B;&#x770B; <code>gsi_common.mk</code>&#xFF1A;</p>
<pre data-role="codeBlock" data-info="Makefile" class="language-makefile">PRODUCT_ARTIFACT_PATH_REQUIREMENT_WHITELIST <span class="token operator">+=</span> \
    system/app/messaging/messaging.apk \
    system/app/WAPPushManager/WAPPushManager.apk \
    system/bin/healthd \
    system/etc/init/healthd.rc \
    system/etc/seccomp_policy/crash_dump.%.policy \
    system/etc/seccomp_policy/mediacodec.policy \
    system/etc/vintf/manifest/manifest_healthd.xml \
    system/lib/libframesequence.so \
    system/lib/libgiftranscode.so \
    system/lib64/libframesequence.so \
    system/lib64/libgiftranscode.so \
</pre><p>&#x7B54;&#x6848;&#x5C31;&#x51FA;&#x6765;&#x4E86;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x6DFB;&#x52A0;&#x5230; System &#x7684;&#x6A21;&#x5757;&#xFF0C;&#x6DFB;&#x52A0;&#x5230; PRODUCT_ARTIFACT_PATH_REQUIREMENT_WHITELIST &#x53D8;&#x91CF;&#x5373;&#x53EF;&#x3002;</p>
<p>&#x4FEE;&#x6539; device/Jelly/Rice14/Rice14.mk&#xFF0C;&#x6DFB;&#x52A0;&#x4EE5;&#x4E0B;&#x5185;&#x5BB9; &#xFF1A;</p>
<pre data-role="codeBlock" data-info class="language-"><code>PRODUCT_ARTIFACT_PATH_REQUIREMENT_WHITELIST += \
    system/bin/helloworld \
</code></pre><p>&#x518D;&#x6B21;&#x7F16;&#x8BD1;&#x6267;&#x884C;&#x5373;&#x53EF;&#x3002;</p>
<p>&#x4EE5;&#x4E0A;&#x7684;&#x65B9;&#x6CD5;&#x662F;&#x53EF;&#x884C;&#x7684;&#xFF0C;&#x4F46;&#x662F;&#x662F;&#x4E0D;&#x63A8;&#x8350;&#x7684;&#xFF0C;&#x5BF9;&#x4E8E;&#x8F6F;&#x4EF6;&#x76F8;&#x5173;&#x7684;&#x5B9A;&#x5236;&#xFF0C;&#x6211;&#x4EEC;&#x5E94;&#x8BE5;&#x5B89;&#x88C5;<a href="https://groups.google.com/g/android-building/c/KE-Sfavd4Ds/m/GDqP5XGMAwAJ">&#x5B98;&#x65B9;&#x8BBA;&#x575B;&#x7684;&#x56DE;&#x590D;</a>&#x7684;&#x8981;&#x6C42;&#x5C06;&#x5176;&#x653E;&#x5230; product &#x5206;&#x533A;&#x3002;</p>
<p>&#x8981;&#x628A; helloworld &#x6A21;&#x5757;&#x653E;&#x5230; product &#x5206;&#x533A;&#x4E5F;&#x5F88;&#x7B80;&#x5355;&#xFF0C;&#x5728;&#x5176; Android.bp &#x4E2D;&#x6DFB;&#x52A0; product_specific: true &#x5373;&#x53EF;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="json" class="language-json">cc_binary <span class="token punctuation">{</span>              <span class="token comment">//&#x6A21;&#x5757;&#x7C7B;&#x578B;&#x4E3A;&#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;</span>
    name<span class="token operator">:</span> <span class="token string">&quot;helloworld&quot;</span><span class="token punctuation">,</span>       <span class="token comment">//&#x6A21;&#x5757;&#x540D;hellobp</span>
    srcs<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;helloworld.cpp&quot;</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token comment">//&#x6E90;&#x6587;&#x4EF6;&#x5217;&#x8868;</span>
    product_specific<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>        <span class="token comment">//&#x7F16;&#x8BD1;&#x51FA;&#x6765;&#x653E;&#x5728;/product&#x76EE;&#x5F55;&#x4E0B;(&#x9ED8;&#x8BA4;&#x662F;&#x653E;&#x5728;/system&#x76EE;&#x5F55;&#x4E0B;)</span>
    cflags<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;-Werror&quot;</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token comment">//&#x6DFB;&#x52A0;&#x7F16;&#x8BD1;&#x9009;&#x9879;</span>
<span class="token punctuation">}</span>
</pre><p>&#x518D;&#x5220;&#x9664; device/Jelly/Rice14/Rice14.mk &#x4E2D;&#x7684;&#x4EE5;&#x4E0B;&#x5185;&#x5BB9; &#xFF1A;</p>
<pre data-role="codeBlock" data-info class="language-"><code>PRODUCT_ARTIFACT_PATH_REQUIREMENT_WHITELIST += \
    system/bin/helloworld \
</code></pre><p>&#x518D;&#x6B21;&#x7F16;&#x8BD1;&#x6267;&#x884C;&#x5373;&#x53EF;&#x3002;</p>
<p>&#x8FD9;&#x91CC;&#x7ED9;&#x51FA;&#x4E00;&#x4E2A;&#x5B89;&#x88C5;&#x4F4D;&#x7F6E;&#x914D;&#x7F6E;&#x7684;&#x603B;&#x7ED3;&#xFF1A;</p>
<ul>
<li>System &#x5206;&#x533A;
<ul>
<li><a href="http://Android.mk">Android.mk</a> &#x9ED8;&#x8BA4;&#x5C31;&#x662F;&#x8F93;&#x51FA;&#x5230; system &#x5206;&#x533A;&#xFF0C;&#x4E0D;&#x7528;&#x6307;&#x5B9A;</li>
<li>Android.bp &#x9ED8;&#x8BA4;&#x5C31;&#x662F;&#x8F93;&#x51FA;&#x5230; system &#x5206;&#x533A;&#xFF0C;&#x4E0D;&#x7528;&#x6307;&#x5B9A;</li>
</ul>
</li>
<li>Vendor
<ul>
<li><a href="http://Android.mk">Android.mk</a> LOCAL_VENDOR_MODULE := true</li>
<li>Android.bp vendor: true</li>
</ul>
</li>
<li>Odm &#x5206;&#x533A;
<ul>
<li><a href="http://Android.mk">Android.mk</a> LOCAL_ODM_MODULE := true</li>
<li>Android.bp device_specific: true</li>
</ul>
</li>
<li>product &#x5206;&#x533A;
<ul>
<li><a href="http://Android.mk">Android.mk</a> LOCAL_PRODUCT_MODULE := true</li>
<li>Android.bp product_specific: true</li>
</ul>
</li>
</ul>
<h4 class="mume-header" id="22-%E5%8F%AF%E6%89%A7%E8%A1%8C%E6%96%87%E4%BB%B6%E6%B7%BB%E5%8A%A0">2.2 &#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;&#x6DFB;&#x52A0;</h4>

<p>&#x6709;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x6DFB;&#x52A0;&#x5230;&#x7CFB;&#x7EDF;&#x7684;&#x7A0B;&#x5E8F;&#x53EA;&#x6709;&#x7F16;&#x8BD1;&#x597D;&#x7684;&#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;&#xFF0C;&#x6CA1;&#x6709;&#x6E90;&#x7801;&#x3002;&#x63A5;&#x4E0B;&#x6765;&#x6211;&#x4EEC;&#x770B;&#x770B;&#x5982;&#x4F55;&#x5728;&#x7CFB;&#x7EDF;&#x6E90;&#x7801;&#x4E2D;&#x6DFB;&#x52A0;&#x4E00;&#x4E2A;&#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;&#xFF1A;</p>
<p>BusyBox &#x662F;&#x6253;&#x5305;&#x4E3A;&#x5355;&#x4E2A;&#x4E8C;&#x8FDB;&#x5236;&#x6587;&#x4EF6;&#x7684;&#x6838;&#x5FC3; Unix &#x5B9E;&#x7528;&#x7A0B;&#x5E8F;&#x7684;&#x96C6;&#x5408;&#x3002;&#x5E38;&#x7528;&#x4E8E;&#x5D4C;&#x5165;&#x5F0F;&#x8BBE;&#x5907;&#x3002;</p>
<p>&#x9002;&#x7528;&#x4E8E; x86 &#x67B6;&#x6784;&#x7684; busybox &#x53EF;&#x901A;&#x8FC7;&#x4EE5;&#x4E0B;&#x547D;&#x4EE4;&#x4E0B;&#x8F7D;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token function">wget</span> https://busybox.net/downloads/binaries/1.30.0-i686/busybox
</pre><p>&#x63A5;&#x4E0B;&#x6765;&#x6211;&#x4EEC;&#x628A;&#x5B83;&#x6DFB;&#x52A0;&#x5230;&#x6211;&#x4EEC;&#x7684; aosp &#x4E2D;&#xFF1A;</p>
<p>&#x5728; <code>device/Jelly/Rice14/</code> &#x76EE;&#x5F55;&#x4E0B;&#x521B;&#x5EFA;&#x5982;&#x4E0B;&#x7684;&#x76EE;&#x5F55;&#x7ED3;&#x6784;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">prebuilt/
&#x2514;&#x2500;&#x2500; busybox
    &#x251C;&#x2500;&#x2500; Android.bp
    &#x2514;&#x2500;&#x2500; busybox
</pre><p>busybox &#x5C31;&#x662F;&#x6211;&#x4EEC;&#x4E4B;&#x524D;&#x7684;&#x4E0B;&#x8F7D;&#x7684;&#x6587;&#x4EF6;&#x3002;</p>
<p>&#x5176;&#x4E2D; Android.bp &#x7684;&#x5185;&#x5BB9;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="json" class="language-json">cc_prebuilt_binary <span class="token punctuation">{</span>
    name<span class="token operator">:</span> <span class="token string">&quot;busybox&quot;</span><span class="token punctuation">,</span>
    srcs<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;busybox&quot;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
    product_specific<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span>
</pre><p>&#x63A5;&#x4E0B;&#x6765;&#x5728; <code>device/Jelly/Rice14/Rice14.mk</code> &#x4E2D;&#x6DFB;&#x52A0;&#x8BE5;&#x6A21;&#x5757;</p>
<pre data-role="codeBlock" data-info="json" class="language-json">PRODUCT_PACKAGES += busybox
</pre><p>&#x7F16;&#x8BD1;&#x6E90;&#x4EE3;&#x7801;&#xFF0C;&#x542F;&#x52A8;&#x6A21;&#x62DF;&#x5668;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token builtin class-name">source</span> build/envsetup.sh
lunch Rice14-eng
<span class="token function">make</span> -j16
emulator
</pre><p>&#x8FDB;&#x5165; adb shell&#xFF0C;&#x6267;&#x884C; busybox &#x547D;&#x4EE4;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">adb shell
busybox
</pre><p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/1674125200821.png" alt></p>
<h3 class="mume-header" id="3-%E6%B7%BB%E5%8A%A0-java-%E5%8F%AF%E6%89%A7%E8%A1%8C%E7%A8%8B%E5%BA%8F">3. &#x6DFB;&#x52A0; Java &#x53EF;&#x6267;&#x884C;&#x7A0B;&#x5E8F;</h3>

<h4 class="mume-header" id="31-%E6%BA%90%E7%A0%81%E6%B7%BB%E5%8A%A0">3.1 &#x6E90;&#x7801;&#x6DFB;&#x52A0;</h4>

<p>&#x5728; <code>device/Jelly/Rice14/</code> &#x76EE;&#x5F55;&#x4E0B;&#x521B;&#x5EFA;&#x4EE5;&#x4E0B;&#x7684;&#x76EE;&#x5F55;&#x548C;&#x6587;&#x4EF6;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">hellojava
&#x251C;&#x2500;&#x2500; Android.bp
&#x2514;&#x2500;&#x2500; com
    &#x2514;&#x2500;&#x2500; ahaoyuandaima
        &#x2514;&#x2500;&#x2500; main
            &#x2514;&#x2500;&#x2500; HelloJava.java
</pre><p>&#x5176;&#x4E2D; Android.bp &#x7684;&#x5185;&#x5BB9;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="json" class="language-json">java_library <span class="token punctuation">{</span>
    name<span class="token operator">:</span> <span class="token string">&quot;hellojava&quot;</span><span class="token punctuation">,</span>
    installable<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
    product_specific<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
    srcs<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;**/*.java&quot;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
    sdk_version<span class="token operator">:</span> <span class="token string">&quot;current&quot;</span>
<span class="token punctuation">}</span>
</pre><p>&#x8FD9;&#x91CC;&#x7740;&#x91CD;&#x89E3;&#x91CA;&#x4E00;&#x4E0B; installable &#x8FD9;&#x4E2A;&#x9009;&#x9879;&#xFF0C;&#x5982;&#x679C;&#x4E0D;&#x6307;&#x5B9A; installable: true, &#x5219;&#x7F16;&#x8BD1;&#x51FA;&#x6765;&#x7684; jar &#x5305;&#x91CC;&#x9762;&#x662F; .class &#x6587;&#x4EF6;&#x3002;&#x8FD9;&#x79CD;&#x5305;&#x662F;&#x6CA1;&#x6CD5;&#x5B89;&#x88C5;&#x5230;&#x7CFB;&#x7EDF;&#x4E0A;&#x7684;&#xFF0C;&#x53EA;&#x80FD;&#x7ED9;&#x5176;&#x4ED6; java &#x6A21;&#x5757;&#x4F5C;&#x4E3A; static_libs &#x4F9D;&#x8D56;&#x3002;</p>
<p>&#x6307;&#x5B9A; installable: true, &#x5219;&#x7F16;&#x8BD1;&#x51FA;&#x6765;&#x7684; jar &#x5305;&#x91CC;&#x9762;&#x662F; classes.dex &#x6587;&#x4EF6;&#x3002;&#x8FD9;&#x79CD;&#x624D;&#x662F; Android &#x865A;&#x62DF;&#x673A;&#x53EF;&#x4EE5;&#x52A0;&#x8F7D;&#x7684;&#x683C;&#x5F0F;&#x3002;</p>
<p>HelloJava.java &#x5185;&#x5BB9;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="cpp" class="language-cpp">package com<span class="token punctuation">.</span>ahaoyuandaima<span class="token punctuation">.</span>main<span class="token punctuation">;</span>

<span class="token keyword keyword-public">public</span> <span class="token keyword keyword-class">class</span> <span class="token class-name">HelloJava</span>
<span class="token punctuation">{</span>
	<span class="token keyword keyword-public">public</span> <span class="token keyword keyword-static">static</span> <span class="token keyword keyword-void">void</span> <span class="token function">main</span><span class="token punctuation">(</span>String<span class="token punctuation">[</span><span class="token punctuation">]</span> args<span class="token punctuation">)</span> 
	<span class="token punctuation">{</span>
		System<span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;Hello Java&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</pre><p>&#x63A5;&#x7740;&#x5728; <code>device/Jelly/Rice14/Rice14.mk</code> &#x4E2D;&#x6DFB;&#x52A0;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">PRODUCT_PACKAGES <span class="token operator">+=</span> <span class="token punctuation">\</span>
    hellojava
</pre><p>&#x63A5;&#x4E0B;&#x6765;&#x7F16;&#x8BD1;&#x7CFB;&#x7EDF;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token builtin class-name">source</span> build/envsetup.sh
lunch Rice14-eng
<span class="token function">make</span> -j16
</pre><p>&#x7F16;&#x8BD1;&#x5B8C;&#x6210;&#x542F;&#x52A8;&#x865A;&#x62DF;&#x673A;&#x540E;&#xFF0C;&#x8FDB;&#x5165; adb shell &#x6267;&#x884C;&#x7A0B;&#x5E8F;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token comment"># &#x8FDB;&#x5165;&#x6A21;&#x62DF;&#x5668;shell</span>
adb shell
<span class="token comment"># &#x914D;&#x7F6E; classpath</span>
<span class="token builtin class-name">export</span> <span class="token assign-left variable">CLASSPATH</span><span class="token operator">=</span>/product/framework/hellojava.jar 
app_process /product/framework/ com.ahaoyuandaima.main.HelloJava
</pre><p>&#x6267;&#x884C;&#x7ED3;&#x679C;&#x5982;&#x4E0B;&#x56FE;&#x6240;&#x793A;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230331180651.png" alt></p>
<h4 class="mume-header" id="32-%E5%8F%AF%E6%89%A7%E8%A1%8C-jar-%E5%8C%85%E6%B7%BB%E5%8A%A0">3.2 &#x53EF;&#x6267;&#x884C; jar &#x5305;&#x6DFB;&#x52A0;</h4>

<p>&#x6709;&#x7684;&#x65F6;&#x5019;&#x6211;&#x4EEC;&#x53EF;&#x80FD;&#x9700;&#x8981;&#x5728;&#x6E90;&#x7801;&#x4E2D;&#x6DFB;&#x52A0;&#x522B;&#x4EBA;&#x7F16;&#x8BD1;&#x597D;&#x7684;&#x53EF;&#x6267;&#x884C; jar &#x5305;&#xFF0C;&#x63A5;&#x7740;&#x6211;&#x4EEC;&#x770B;&#x770B;&#x5177;&#x4F53;&#x600E;&#x4E48;&#x64CD;&#x4F5C;&#xFF1A;</p>
<p>&#x5728; <code>device/Jelly/Rice14/</code> &#x76EE;&#x5F55;&#x4E0B;&#x521B;&#x5EFA;&#x4EE5;&#x4E0B;&#x7684;&#x76EE;&#x5F55;&#x548C;&#x6587;&#x4EF6;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">hellojavajar
&#x251C;&#x2500;&#x2500; Android.bp
&#x2514;&#x2500;&#x2500; hellojava.jar
</pre><p>&#x5176;&#x4E2D; hellojava.jar&#xFF0C;&#x662F;&#x4ECE; <code>out/target/product/Rice14/system/product/framework/hellojava.jar</code> &#x79FB;&#x52A8;&#x8FC7;&#x6765;&#x7684;&#x3002;</p>
<p>Android.bp &#x7684;&#x5185;&#x5BB9;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="json" class="language-json">java_import <span class="token punctuation">{</span>
    name<span class="token operator">:</span> <span class="token string">&quot;hellojavajar&quot;</span><span class="token punctuation">,</span>
    installable<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
    jars<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;hellojava.jar&quot;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
    product_specific<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>   
<span class="token punctuation">}</span>
</pre><p>&#x4E3A;&#x4E86;&#x907F;&#x514D;&#x51B2;&#x7A81;&#xFF0C;&#x6211;&#x4EEC;&#x628A; hellojava &#x6587;&#x4EF6;&#x5939;&#x5220;&#x9664;&#x3002;&#x5728; <code>device/Jelly/Rice14/Rice14.mk</code> &#x4E2D;&#x5220;&#x9664;&#x5DF2;&#x6DFB;&#x52A0;&#x7684; hellojava &#x6A21;&#x5757;&#x3002;&#x5E76;&#x91CD;&#x65B0;&#x6DFB;&#x52A0; javahellojar &#x6A21;&#x5757;</p>
<pre data-role="codeBlock" data-info="Makefile" class="language-makefile">PRODUCT_PACKAGES <span class="token operator">+=</span> \
    hellojavajar
</pre><p>&#x63A5;&#x4E0B;&#x6765;&#x7F16;&#x8BD1;&#x7CFB;&#x7EDF;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token builtin class-name">source</span> build/envsetup.sh
lunch Rice14-eng
<span class="token function">make</span> -j16
</pre><p>&#x7F16;&#x8BD1;&#x5B8C;&#x6210;&#x542F;&#x52A8;&#x865A;&#x62DF;&#x673A;&#x540E;&#xFF0C;&#x8FDB;&#x5165; adb shell &#x6267;&#x884C;&#x7A0B;&#x5E8F;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token comment"># &#x8FDB;&#x5165;&#x6A21;&#x62DF;&#x5668;shell</span>
adb shell
<span class="token comment"># &#x914D;&#x7F6E; classpath</span>
<span class="token builtin class-name">export</span> <span class="token assign-left variable">CLASSPATH</span><span class="token operator">=</span>/product/framework/hellojava.jar
<span class="token comment"># &#x6267;&#x884C;&#x53EF;&#x6267;&#x884C;&#x7A0B;&#x5E8F; </span>
app_process /product/framework/ com.ahaoyuandaima.main.HelloJava
</pre><h3 class="mume-header" id="%E6%80%BB%E7%BB%93">&#x603B;&#x7ED3;</h3>

<p>&#x672C;&#x6587;&#x4E3B;&#x8981;&#x8BB2;&#x89E3;&#x4E86;&#x5982;&#x4F55;&#x5C06;</p>
<ul>
<li>C/C++ &#x53EF;&#x6267;&#x884C;&#x7A0B;&#x5E8F;&#x6E90;&#x7801;</li>
<li>Java &#x53EF;&#x6267;&#x884C;&#x7A0B;&#x5E8F;&#x6E90;&#x7801;</li>
</ul>
<p>&#x4E24;&#x7C7B;&#x6A21;&#x5757;&#x6DFB;&#x52A0;&#x5230;&#x6E90;&#x7801;&#x4E2D;&#xFF0C;&#x4EE5;&#x5B9E;&#x9645;&#x64CD;&#x4F5C;&#x4E3A;&#x4E3B;&#xFF0C;&#x540C;&#x5B66;&#x4EEC;&#x53EF;&#x4EE5;&#x81EA;&#x5DF1;&#x5B9E;&#x8DF5;&#x4F53;&#x9A8C;&#x3002;</p>
<h2 class="mume-header" id="%E7%AC%AC%E4%BA%94%E7%AB%A0-%E6%B7%BB%E5%8A%A0-cc-java-%E5%BA%93">&#x7B2C;&#x4E94;&#x7AE0; &#x6DFB;&#x52A0; C/C++&#x3001;Java &#x5E93;</h2>

<h3 class="mume-header" id="1%E6%B7%BB%E5%8A%A0-cc-%E7%A8%8B%E5%BA%8F%E5%BA%93">1.&#x6DFB;&#x52A0; C/C++ &#x7A0B;&#x5E8F;&#x5E93;</h3>

<h4 class="mume-header" id="11-%E6%BA%90%E7%A0%81%E6%96%B9%E5%BC%8F%E6%B7%BB%E5%8A%A0">1.1 &#x6E90;&#x7801;&#x65B9;&#x5F0F;&#x6DFB;&#x52A0;</h4>

<p>&#x5728; <code>device/Jelly/Rice14/</code> &#x76EE;&#x5F55;&#x4E0B;&#x521B;&#x5EFA;&#x4EE5;&#x4E0B;&#x7684;&#x76EE;&#x5F55;&#x548C;&#x6587;&#x4EF6;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">libmymath
&#x251C;&#x2500;&#x2500; Android.bp
&#x251C;&#x2500;&#x2500; my_math.cpp
&#x2514;&#x2500;&#x2500; my_math.h
</pre><p><strong>libmymath</strong> &#x662F;&#x4E00;&#x4E2A;&#x52A8;&#x6001;&#x5E93;&#x3002;&#x5176; <code>Android.bp</code> &#x5185;&#x5BB9;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="json" class="language-json">cc_library_shared <span class="token punctuation">{</span>
    name<span class="token operator">:</span> <span class="token string">&quot;libmymath&quot;</span><span class="token punctuation">,</span>

    srcs<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;my_math.cpp&quot;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>

    export_include_dirs<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;.&quot;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>

    product_specific<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>

<span class="token punctuation">}</span>
</pre><p>my_math.h &#x5185;&#x5BB9;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="c++" class="language-cpp"><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">ifndef</span> <span class="token expression">__MY_MATH_H__</span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">define</span> <span class="token macro-name">__MY_MATH_H__</span></span>

<span class="token keyword keyword-int">int</span> <span class="token function">my_add</span><span class="token punctuation">(</span><span class="token keyword keyword-int">int</span> a<span class="token punctuation">,</span> <span class="token keyword keyword-int">int</span> b<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword keyword-int">int</span> <span class="token function">my_sub</span><span class="token punctuation">(</span><span class="token keyword keyword-int">int</span> a<span class="token punctuation">,</span> <span class="token keyword keyword-int">int</span> b<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">endif</span></span>
</pre><p>my_math.cpp &#x5185;&#x5BB9;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="c++" class="language-cpp"><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&quot;my_math.h&quot;</span></span>

<span class="token keyword keyword-int">int</span> <span class="token function">my_add</span><span class="token punctuation">(</span><span class="token keyword keyword-int">int</span> a<span class="token punctuation">,</span> <span class="token keyword keyword-int">int</span> b<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
	<span class="token keyword keyword-return">return</span> a <span class="token operator">+</span> b<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword keyword-int">int</span> <span class="token function">my_sub</span><span class="token punctuation">(</span><span class="token keyword keyword-int">int</span> a<span class="token punctuation">,</span> <span class="token keyword keyword-int">int</span> b<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
	<span class="token keyword keyword-return">return</span> a <span class="token operator">-</span> b<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</pre><p>&#x63A5;&#x7740;&#x4FEE;&#x6539;&#x6211;&#x4EEC;&#x4E4B;&#x524D;&#x6DFB;&#x52A0;&#x7684; hello &#x9879;&#x76EE;&#xFF1A;</p>
<p>&#x4FEE;&#x6539; <code>hello.cpp</code></p>
<pre data-role="codeBlock" data-info="c++" class="language-cpp"><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;cstdio&gt;</span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&quot;my_math.h&quot;</span> <span class="token comment">//&#x6DFB;&#x52A0;&#x5934;&#x6587;&#x4EF6;</span></span>

<span class="token keyword keyword-int">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">&quot;Hello Android %d \n&quot;</span><span class="token punctuation">,</span> <span class="token function">my_add</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//&#x6DFB;&#x52A0;&#x51FD;&#x6570;&#x8C03;&#x7528;</span>
    <span class="token keyword keyword-return">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</pre><p>&#x4FEE;&#x6539; Android.bp&#xFF1A;</p>
<pre data-role="codeBlock" data-info="json" class="language-json">cc_binary <span class="token punctuation">{</span>              
    name<span class="token operator">:</span> <span class="token string">&quot;hello&quot;</span><span class="token punctuation">,</span>       
    srcs<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;hello.cpp&quot;</span><span class="token punctuation">]</span><span class="token punctuation">,</span> 
    cflags<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;-Werror&quot;</span><span class="token punctuation">]</span><span class="token punctuation">,</span> 
    product_specific<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>        
    shared_libs<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;libmymath&quot;</span><span class="token punctuation">]</span>    <span class="token comment">//&#x6DFB;&#x52A0;&#x52A8;&#x6001;&#x5E93;&#x4F9D;&#x8D56;</span>
<span class="token punctuation">}</span>
</pre><p>&#x63A5;&#x4E0B;&#x6765;&#x7F16;&#x8BD1;&#x7CFB;&#x7EDF;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token builtin class-name">source</span> build/envsetup.sh
lunch Rice14-eng
<span class="token function">make</span> -j16
</pre><p>&#x7F16;&#x8BD1;&#x5B8C;&#x6210;&#x542F;&#x52A8;&#x865A;&#x62DF;&#x673A;&#x540E;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x901A;&#x8FC7; adb shell &#x8FD0;&#x884C;&#x6211;&#x4EEC;&#x7684; hello &#x7A0B;&#x5E8F;&#x4E86;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">emulator
adb shell hello
</pre><p>&#x6267;&#x884C;&#x7ED3;&#x679C;&#x5982;&#x4E0B;&#x56FE;&#x6240;&#x793A;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230402121506.png" alt></p>
<h4 class="mume-header" id="12-so-%E5%8C%85%E6%96%B9%E5%BC%8F%E6%B7%BB%E5%8A%A0">1.2 so &#x5305;&#x65B9;&#x5F0F;&#x6DFB;&#x52A0;</h4>

<p>&#x5728; <code>device/Jelly/Rice14</code> &#x76EE;&#x5F55;&#x4E0B;&#x521B;&#x5EFA;&#x5982;&#x4E0B;&#x7684;&#x6587;&#x4EF6;&#x4E0E;&#x6587;&#x4EF6;&#x5939;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">libmymathprebuild
&#x251C;&#x2500;&#x2500; Android.bp
&#x251C;&#x2500;&#x2500; include
&#x2502;   &#x2514;&#x2500;&#x2500; my_math.h
&#x2514;&#x2500;&#x2500; lib
    &#x251C;&#x2500;&#x2500; x86
    &#x2502;   &#x2514;&#x2500;&#x2500; libmymath.so
    &#x2514;&#x2500;&#x2500; x86_64
        &#x2514;&#x2500;&#x2500; libmymath.so
</pre><ul>
<li>&#x5176;&#x4E2D; <a href="http://libmymath.so">libmymath.so</a> &#x662F;&#x4E0A;&#x4E00;&#x8282;&#x4E2D;&#x7684;&#x7F16;&#x8BD1;&#x4EA7;&#x7269;&#xFF0C;x86/libmymath.so &#x62F7;&#x8D1D;&#x81EA; out/target/product/Rice14/system/product/lib/libmymath.so</li>
<li>x86_64/libmymath.so &#x62F7;&#x8D1D;&#x81EA; out/target/product/Rice14/system/product/lib64/libmymath.so</li>
<li>my_math.h &#x662F;&#x4E0A;&#x4E00;&#x8282;&#x4E2D; libmymath &#x6A21;&#x5757;&#x4E2D;&#x62F7;&#x8D1D;&#x8FC7;&#x6765;&#x7684;&#x5934;&#x6587;&#x4EF6;</li>
</ul>
<p>Android.bp &#x7684;&#x5185;&#x5BB9;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="json" class="language-json">cc_prebuilt_library_shared <span class="token punctuation">{</span>
    name<span class="token operator">:</span> <span class="token string">&quot;libmymathprebuild&quot;</span><span class="token punctuation">,</span>

     arch<span class="token operator">:</span> <span class="token punctuation">{</span>
        x86<span class="token operator">:</span> <span class="token punctuation">{</span>
            srcs<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;lib/x86/libmymath.so&quot;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        x86_64<span class="token operator">:</span> <span class="token punctuation">{</span>
            srcs<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;lib/x86_64/libmymath.so&quot;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>

    export_include_dirs<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;include&quot;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>

    product_specific<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>

<span class="token punctuation">}</span>
</pre><p>&#x4E3A;&#x4E86;&#x907F;&#x514D;&#x51B2;&#x7A81;&#xFF0C;&#x6211;&#x4EEC;&#x628A;&#x4E0A;&#x4E00;&#x8282;&#x6DFB;&#x52A0;&#x7684; <code>libmymath</code> &#x79FB;&#x51FA;&#x7CFB;&#x7EDF;&#x6E90;&#x7801;&#x76EE;&#x5F55;&#x6216;&#x8005;&#x5220;&#x9664;&#x3002;</p>
<p>&#x63A5;&#x4E0B;&#x6765;&#xFF0C;&#x7F16;&#x8BD1;&#x6574;&#x4E2A;&#x7CFB;&#x7EDF;&#xFF0C;&#x5F00;&#x542F;&#x865A;&#x62DF;&#x673A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token builtin class-name">source</span> build/envsetup.sh
lunch Rice14-eng
<span class="token function">make</span> -j16
emulator
</pre><p>&#x63A5;&#x4E0B;&#x6765;&#x6267;&#x884C; hello &#x7A0B;&#x5E8F;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">adb shell hello
</pre><p>&#x6267;&#x884C;&#x7ED3;&#x679C;&#x5982;&#x4E0B;&#x56FE;&#x6240;&#x793A;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230402132353.png" alt></p>
<h3 class="mume-header" id="2-%E6%B7%BB%E5%8A%A0-java-%E5%BA%93">2. &#x6DFB;&#x52A0; Java &#x5E93;</h3>

<h4 class="mume-header" id="21-%E6%BA%90%E7%A0%81%E6%96%B9%E5%BC%8F%E6%B7%BB%E5%8A%A0">2.1 &#x6E90;&#x7801;&#x65B9;&#x5F0F;&#x6DFB;&#x52A0;</h4>

<p>&#x5728; <code>device/Jelly/Rice14/</code> &#x76EE;&#x5F55;&#x4E0B;&#x521B;&#x5EFA;&#x4EE5;&#x4E0B;&#x7684;&#x76EE;&#x5F55;&#x548C;&#x6587;&#x4EF6;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">libmymathjava
&#x251C;&#x2500;&#x2500; Android.bp
&#x2514;&#x2500;&#x2500; com
    &#x2514;&#x2500;&#x2500; yuandaima
        &#x2514;&#x2500;&#x2500; mymath
            &#x2514;&#x2500;&#x2500; MyMath.java
</pre><p>libmymathjava &#x662F;&#x4E00;&#x4E2A; java &#x5E93;&#x3002;&#x5176; Android.bp &#x5185;&#x5BB9;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="json" class="language-json">java_library <span class="token punctuation">{</span>
    name<span class="token operator">:</span> <span class="token string">&quot;libmymathjava&quot;</span><span class="token punctuation">,</span>
    installable<span class="token operator">:</span> <span class="token boolean">false</span><span class="token punctuation">,</span>
    product_specific<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
    srcs<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;**/*.java&quot;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
    sdk_version<span class="token operator">:</span> <span class="token string">&quot;current&quot;</span>
<span class="token punctuation">}</span>
</pre><p>&#x5982;&#x679C;&#x4E0D;&#x6307;&#x5B9A; installable: true, &#x5219;&#x7F16;&#x8BD1;&#x51FA;&#x6765;&#x7684; jar &#x5305;&#x91CC;&#x9762;&#x662F; .class &#x6587;&#x4EF6;&#x3002;&#x8FD9;&#x79CD;&#x5305;&#x662F;&#x6CA1;&#x6CD5;&#x5B89;&#x88C5;&#x5230;&#x7CFB;&#x7EDF;&#x4E0A;&#x7684;&#xFF0C;&#x53EA;&#x80FD;&#x7ED9;&#x5176;&#x4ED6; java &#x6A21;&#x5757;&#x4F5C;&#x4E3A; static_libs &#x4F9D;&#x8D56;&#x3002;&#x6700;&#x7EC8;&#x751F;&#x6210;&#x7684; jar &#x5305;&#x4E0D;&#x4F1A;&#x88AB;&#x76F4;&#x63A5;&#x5B58;&#x653E;&#x5230; Android &#x7684;&#x6587;&#x4EF6;&#x7CFB;&#x7EDF;&#x4E2D;&#xFF0C;&#x800C;&#x662F;&#x6253;&#x5305;&#x8FDB;&#x4F9D;&#x8D56;&#x4E8E;&#x5F53;&#x524D;&#x6A21;&#x5757;&#x7684;&#x5176;&#x4ED6;&#x6A21;&#x5757;&#x4E2D;&#x3002;</p>
<p>MyMath.java &#x5185;&#x5BB9;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="cpp" class="language-cpp">package com<span class="token punctuation">.</span>yuandaima<span class="token punctuation">.</span>mymath<span class="token punctuation">;</span>

<span class="token keyword keyword-public">public</span> <span class="token keyword keyword-class">class</span> <span class="token class-name">MyMath</span>
<span class="token punctuation">{</span>

    <span class="token keyword keyword-public">public</span> <span class="token function">MyMath</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>

    <span class="token punctuation">}</span>

	<span class="token keyword keyword-public">public</span> <span class="token keyword keyword-int">int</span> <span class="token function">add</span><span class="token punctuation">(</span><span class="token keyword keyword-int">int</span> a<span class="token punctuation">,</span> <span class="token keyword keyword-int">int</span> b<span class="token punctuation">)</span>
	<span class="token punctuation">{</span>
		<span class="token keyword keyword-return">return</span> <span class="token punctuation">(</span>a<span class="token operator">+</span>b<span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>

<span class="token punctuation">}</span>
</pre><p>&#x63A5;&#x7740;&#x6211;&#x4EEC;&#x628A; helllojavajar &#x5220;&#x9664;&#xFF0C;&#x5C06;&#x4E4B;&#x524D;&#x5199;&#x597D;&#x7684; hellojava &#x6A21;&#x5757;&#x79FB;&#x52A8;&#x5230; <code>device/Jelly/Rice14</code> &#x76EE;&#x5F55;&#x4E0B;&#xFF0C;&#x5E76;&#x505A;&#x4EE5;&#x4E0B;&#x4FEE;&#x6539;&#xFF1A;</p>
<p>&#x4FEE;&#x6539; helljava/Android.bp:</p>
<pre data-role="codeBlock" data-info="json" class="language-json">java_library <span class="token punctuation">{</span>
    name<span class="token operator">:</span> <span class="token string">&quot;hellojava&quot;</span><span class="token punctuation">,</span>
    installable<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
    product_specific<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
    srcs<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;**/*.java&quot;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
    sdk_version<span class="token operator">:</span> <span class="token string">&quot;current&quot;</span><span class="token punctuation">,</span>
    static_libs<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;libmymathjavajar&quot;</span><span class="token punctuation">]</span>
<span class="token punctuation">}</span>
</pre><p>&#x5728; <code>device/Jelly/Rice14/Rice14.mk</code> &#x4E2D;&#x6DFB;&#x52A0;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">PRODUCT_PACKAGES <span class="token operator">+=</span> hellojava
</pre><p>&#x63A5;&#x4E0B;&#x6765;&#x7F16;&#x8BD1;&#x7CFB;&#x7EDF;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token builtin class-name">source</span> build/envsetup.sh
lunch Rice14-eng
<span class="token function">make</span> -j16
</pre><p>&#x7F16;&#x8BD1;&#x5B8C;&#x6210;&#x542F;&#x52A8;&#x865A;&#x62DF;&#x673A;&#x540E;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token comment"># &#x8FDB;&#x5165;&#x6A21;&#x62DF;&#x5668;shell</span>
adb shell
<span class="token comment"># &#x914D;&#x7F6E; classpath</span>
<span class="token builtin class-name">export</span> <span class="token assign-left variable">CLASSPATH</span><span class="token operator">=</span>/product/framework/hellojava.jar
app_process /product/framework/ com.ahaoyuandaima.main.HelloJava 
</pre><p>&#x6267;&#x884C;&#x7ED3;&#x679C;&#x5982;&#x4E0B;&#x56FE;&#x6240;&#x793A;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230402150426.png" alt></p>
<h4 class="mume-header" id="22-jar-%E5%8C%85%E6%96%B9%E5%BC%8F%E6%B7%BB%E5%8A%A0">2.2 Jar &#x5305;&#x65B9;&#x5F0F;&#x6DFB;&#x52A0;</h4>

<p>&#x5728;&#x7CFB;&#x7EDF;&#x6E90;&#x7801;&#x76EE;&#x5F55;&#x4E0B;&#x6267;&#x884C;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token builtin class-name">source</span> build/envsetup.sh
lunch Rice14-eng
</pre><p>&#x63A5;&#x4E0B;&#x6765;&#x7F16;&#x8BD1;&#x83B7;&#x5F97; jar &#x5305;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token builtin class-name">cd</span> device/Jelly/Rice14/libmymathjava
mm
<span class="token comment">#&#x7F16;&#x8BD1;&#x5B8C;&#x6210;&#x540E;&#xFF0C;&#x4F1A;&#x6253;&#x5370;&#x51FA;&#x7F16;&#x8BD1;&#x4EA7;&#x7269;&#x8DEF;&#x5F84; out/target/product/Rice14/obj/JAVA_LIBRARIES/libmymathjava_intermediates/javalib.jar</span>
</pre><p>&#x4E3A;&#x907F;&#x514D;&#x51B2;&#x7A81;&#x6211;&#x4EEC;&#x628A;  <code>device/Jelly/Rice14/libmymathjava</code> &#x79FB;&#x52A8;&#x5230;&#x6E90;&#x7801;&#x4EE5;&#x5916;&#x7684;&#x76EE;&#x5F55;&#x6216;&#x8005;&#x5220;&#x9664;</p>
<p>&#x5728; <code>device/Jelly/Rice14/</code> &#x4E0B;&#x91CD;&#x65B0;&#x521B;&#x5EFA;&#x5982;&#x4E0B;&#x7684;&#x76EE;&#x5F55;&#x7ED3;&#x6784;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">libmymathjavajar
&#x251C;&#x2500;&#x2500; Android.bp
&#x2514;&#x2500;&#x2500; libmymathjava.jar
</pre><p>&#x5176;&#x4E2D; <code>libmymathjava.jar</code> &#x662F;&#x62F7;&#x8D1D;&#x81EA;&#x7F16;&#x8BD1;&#x4EA7;&#x7269; <code>out/target/product/Rice14/obj/JAVA_LIBRARIES/libmymathjava_intermediates/javalib.jar</code>&#xFF0C;&#x5E76;&#x6539;&#x540D;&#x4E3A; libmymathjava.jar</p>
<p>Android.bp &#x7684;&#x5185;&#x5BB9;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="json" class="language-json">java_import <span class="token punctuation">{</span>
    name<span class="token operator">:</span> <span class="token string">&quot;libmymathjavajar&quot;</span><span class="token punctuation">,</span>
    installable<span class="token operator">:</span> <span class="token boolean">false</span><span class="token punctuation">,</span>
    jars<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;libmymathjava.jar&quot;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
    product_specific<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>   
<span class="token punctuation">}</span>
</pre><p>&#x63A5;&#x7740;&#x4FEE;&#x6539; hellojava &#x6A21;&#x5757;&#x7684;&#x4F9D;&#x8D56;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="json" class="language-json">java_library <span class="token punctuation">{</span>
    name<span class="token operator">:</span> <span class="token string">&quot;hellojava&quot;</span><span class="token punctuation">,</span>
    installable<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
    product_specific<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
    srcs<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;**/*.java&quot;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
    sdk_version<span class="token operator">:</span> <span class="token string">&quot;current&quot;</span><span class="token punctuation">,</span>
    static_libs<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;libmymathjavajar&quot;</span><span class="token punctuation">]</span>  <span class="token comment">//&#x4FEE;&#x6539;&#x8FD9;&#x91CC;</span>
<span class="token punctuation">}</span>
</pre><p>&#x7F16;&#x8BD1;&#x7CFB;&#x7EDF;&#xFF0C;&#x5E76;&#x542F;&#x52A8;&#x6A21;&#x62DF;&#x5668;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token builtin class-name">source</span> build/envsetup.sh
lunch Rice14-eng
<span class="token function">make</span> -j16
emulator
</pre><p>&#x9A8C;&#x8BC1; libmymathjavajar &#x6A21;&#x5757;&#x662F;&#x5426;&#x88AB;&#x6B63;&#x786E;&#x7F16;&#x8BD1;&#x5230; hellojava &#x6A21;&#x5757;&#x4E2D;&#x3002;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token comment"># &#x8FDB;&#x5165;&#x6A21;&#x62DF;&#x5668;shell</span>
adb shell
<span class="token comment"># &#x914D;&#x7F6E; classpath</span>
<span class="token builtin class-name">export</span> <span class="token assign-left variable">CLASSPATH</span><span class="token operator">=</span>/product/framework/hellojava.jar
app_process /product/framework/ com.ahaoyuandaima.main.HelloJava 
</pre><p>&#x6267;&#x884C;&#x7ED3;&#x679C;&#x5982;&#x4E0B;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230402153537.png" alt></p>
<h2 class="mume-header" id="%E7%AC%AC%E5%85%AD%E7%AB%A0-%E6%B7%BB%E5%8A%A0%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E4%B8%8E%E5%88%A0%E9%99%A4%E5%B7%B2%E6%9C%89%E6%A8%A1%E5%9D%97">&#x7B2C;&#x516D;&#x7AE0; &#x6DFB;&#x52A0;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4E0E;&#x5220;&#x9664;&#x5DF2;&#x6709;&#x6A21;&#x5757;</h2>

<h3 class="mume-header" id="1-%E6%B7%BB%E5%8A%A0%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6">1. &#x6DFB;&#x52A0;&#x914D;&#x7F6E;&#x6587;&#x4EF6;</h3>

<p>PRODUCT_COPY_FILES &#x5E38;&#x7528;&#x4E8E;&#x4EA7;&#x54C1;&#x7684;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4E2D;&#xFF0C;&#x5728;&#x672C;&#x6587;&#x4E2D;&#x5C31;&#x662F; <a href="http://Rice14.mk">Rice14.mk</a> &#x6587;&#x4EF6;&#xFF0C;&#x7528;&#x4E8E;&#x5C06;&#x6E90;&#x7801;&#x7684;&#x6587;&#x4EF6;&#x62F7;&#x8D1D;&#x5230; Android &#x6587;&#x4EF6;&#x7CFB;&#x7EDF;&#x4E2D;&#x3002;</p>
<p>&#x8FD9;&#x91CC;&#x770B;&#x4E00;&#x4E2A;&#x6E90;&#x7801;&#x4E2D;&#x7684;&#x793A;&#x4F8B;&#xFF1A;</p>
<p><code>aosp/build/target/product/core_64_bit.mk</code> &#x4E2D;&#x6709;&#x5982;&#x4E0B;&#x5185;&#x5BB9;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="makefile" class="language-makefile">PRODUCT_COPY_FILES <span class="token operator">+=</span> system/core/rootdir/init.zygote64_32.rc<span class="token punctuation">:</span>system/etc/init/hw/init.zygote64_32.rc
</pre><p>&#x8FD9;&#x4E00;&#x884C;&#x8868;&#x793A;&#x5C06;&#x6E90;&#x7801;&#x4E2D;&#x7684; <code>system/core/rootdir/init.zygote64_32.rc</code> &#x62F7;&#x8D1D;&#x5230; Android &#x6587;&#x4EF6;&#x7CFB;&#x7EDF;&#x7684; system/etc/init/hw/init.zygote64_32.rc &#x6587;&#x4EF6;&#x4E2D;&#x3002;</p>
<p>init.zygote64_32.rc &#x662F; init &#x7A0B;&#x5E8F;&#x4F7F;&#x7528;&#x7684;&#x4E00;&#x4E2A;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#xFF0C;&#x5F53;&#x6211;&#x4EEC;&#x7684;&#x7A0B;&#x5E8F;&#x9700;&#x8981;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x65F6;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x53C2;&#x8003;&#x4EE5;&#x4E0A;&#x7684;&#x65B9;&#x5F0F;&#x6765;&#x5B8C;&#x6210;&#x3002;</p>
<h3 class="mume-header" id="2-%E5%88%A0%E9%99%A4%E5%B7%B2%E6%9C%89%E6%A8%A1%E5%9D%97">2. &#x5220;&#x9664;&#x5DF2;&#x6709;&#x6A21;&#x5757;</h3>

<p>&#x6709;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x5220;&#x9664;&#x7CFB;&#x7EDF;&#x4E2D;&#x5DF2;&#x6709;&#x7684;&#x6A21;&#x5757;&#xFF0C;&#x6BD4;&#x5982;&#x6211;&#x4EEC;&#x7CFB;&#x7EDF;&#x7684;&#x5E94;&#x7528;&#x573A;&#x666F;&#x662F;&#x5E7F;&#x544A;&#x724C;&#x3001;&#x7535;&#x89C6;&#xFF0C;&#x90A3;&#x6211;&#x4EEC;&#x5C31;&#x9700;&#x8981;&#x5220;&#x9664;&#x7535;&#x8BDD;&#xFF0C;&#x901A;&#x4FE1;&#x5F55;&#x7B49;&#x5E94;&#x7528;&#x3002;&#x4E0B;&#x9762;&#x4EE5;&#x5220;&#x9664;&#x901A;&#x4FE1;&#x5F55;&#xFF08;Contacts&#xFF09;&#x4E3A;&#x4F8B;&#xFF0C;&#x6F14;&#x793A;&#x5982;&#x4F55;&#x64CD;&#x4F5C;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token function">grep</span> -r <span class="token string">&quot;Contacts&quot;</span> <span class="token builtin class-name">.</span>
./make/target/product/handheld_product.mk:    Contacts <span class="token punctuation">\</span>
./make/target/product/mainline_arm64.mk:  system/priv-app/Contacts/Contacts.apk <span class="token punctuation">\</span>
./make/target/product/base_system.mk:    ContactsProvider <span class="token punctuation">\</span>
./make/core/build-system.html:Dialer, Contacts, etc.  This will probably change or go away when we switch
</pre><p>&#x5728; <code>./make/target/product/handheld_product.mk</code> &#x4E2D;&#x5220;&#x9664; PRODUCT_PACKAGES &#x53D8;&#x91CF;&#x7684; Contacts</p>
<p>&#x63A5;&#x7740;&#x91CD;&#x65B0;&#x7F16;&#x8BD1;&#x542F;&#x52A8;&#x6A21;&#x62DF;&#x5668;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token builtin class-name">source</span> build/envsetup.sh
lunch Rice14-eng
<span class="token function">make</span> clean
<span class="token function">make</span> -j16
emulator
</pre><p>&#x53EF;&#x4EE5;&#x770B;&#x5230;&#xFF0C;Contacts &#x5E94;&#x7528;&#x5DF2;&#x7ECF;&#x6CA1;&#x6709;&#x4E86;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230403115334.png" alt></p>
<h2 class="mume-header" id="%E7%AC%AC%E4%B8%83%E7%AB%A0-%E6%B7%BB%E5%8A%A0%E7%B3%BB%E7%BB%9F-app-%E6%BA%90%E7%A0%81">&#x7B2C;&#x4E03;&#x7AE0; &#x6DFB;&#x52A0;&#x7CFB;&#x7EDF; App &#x6E90;&#x7801;</h2>

<h3 class="mume-header" id="1-%E5%A6%82%E4%BD%95%E6%96%B0%E5%BB%BA%E4%B8%80%E4%B8%AA%E7%B3%BB%E7%BB%9F-app-%E9%A1%B9%E7%9B%AE">1. &#x5982;&#x4F55;&#x65B0;&#x5EFA;&#x4E00;&#x4E2A;&#x7CFB;&#x7EDF; App &#x9879;&#x76EE;</h3>

<p>&#x4F7F;&#x7528; Android Studio &#x65B0;&#x5EFA;&#x4E00;&#x4E2A;&#x7A7A;&#x9879;&#x76EE; FirstSystemApp&#xFF0C;&#x5305;&#x540D;&#x8BBE;&#x7F6E;&#x4E3A; <code>com.yuandaima.firstsystemapp</code>&#xFF0C;&#x8BED;&#x8A00;&#x9009;&#x62E9; Java&#x3002;&#x540E;&#x9762;&#x4E3A;&#x53D9;&#x8FF0;&#x65B9;&#x4FBF;&#x79F0;&#x8BE5;&#x9879;&#x76EE;&#x4E3A; as &#x9879;&#x76EE;&#x3002;</p>
<p>&#x63A5;&#x7740;&#x5728; <code>jelly/rice14</code> &#x76EE;&#x5F55;&#x4E0B;&#x521B;&#x5EFA;&#x5982;&#x4E0B;&#x7684;&#x76EE;&#x5F55;&#x548C;&#x6587;&#x4EF6;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230227131236.png" alt></p>
<p>&#x63A5;&#x7740;&#x5C06; as &#x9879;&#x76EE;&#x4E2D;&#x7684; res &#x6587;&#x4EF6;&#x4E0B;&#x7684;&#x8D44;&#x6E90;&#x6587;&#x4EF6;&#x62F7;&#x8D1D;&#x5230; <code>Jelly/Rice14/FirstSystemApp/res</code> &#x4E2D;&#xFF0C;&#x628A; as &#x9879;&#x76EE;&#x4E2D;&#x7684; MainActivity.java &#x62F7;&#x8D1D;&#x5230; <code>Jelly/Rice14/FirstSystemApp/src/com/yuandaima/firstsystemapp</code> &#x4E2D;&#x3002;</p>
<p>&#x63A5;&#x7740;&#x4FEE;&#x6539;&#x5DF2;&#x6DFB;&#x52A0;&#x7684; AndroidManifest.xml &#x6587;&#x4EF6;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="xml" class="language-xml"><span class="token prolog">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>manifest</span> <span class="token attr-name"><span class="token namespace">xmlns:</span>android</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://schemas.android.com/apk/res/android<span class="token punctuation">&quot;</span></span>
    <span class="token attr-name">package</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>com.yuandaima.firstsystemapp<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>application</span>
        <span class="token attr-name"><span class="token namespace">android:</span>icon</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>@mipmap/ic_launcher<span class="token punctuation">&quot;</span></span>
        <span class="token attr-name"><span class="token namespace">android:</span>label</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>@string/app_name<span class="token punctuation">&quot;</span></span>
        <span class="token attr-name"><span class="token namespace">android:</span>supportsRtl</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>true<span class="token punctuation">&quot;</span></span>
        <span class="token attr-name"><span class="token namespace">android:</span>theme</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>@style/Theme.FirstSystemApp<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>activity</span>
            <span class="token attr-name"><span class="token namespace">android:</span>name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>.MainActivity<span class="token punctuation">&quot;</span></span>
            <span class="token attr-name"><span class="token namespace">android:</span>exported</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>true<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>intent-filter</span><span class="token punctuation">&gt;</span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>action</span> <span class="token attr-name"><span class="token namespace">android:</span>name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>android.intent.action.MAIN<span class="token punctuation">&quot;</span></span> <span class="token punctuation">/&gt;</span></span>

                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>category</span> <span class="token attr-name"><span class="token namespace">android:</span>name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>android.intent.category.LAUNCHER<span class="token punctuation">&quot;</span></span> <span class="token punctuation">/&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>intent-filter</span><span class="token punctuation">&gt;</span></span>

            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta-data</span>
                <span class="token attr-name"><span class="token namespace">android:</span>name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>android.app.lib_name<span class="token punctuation">&quot;</span></span>
                <span class="token attr-name"><span class="token namespace">android:</span>value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span><span class="token punctuation">&quot;</span></span> <span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>activity</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>application</span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>manifest</span><span class="token punctuation">&gt;</span></span>
</pre><p>&#x63A5;&#x7740;&#x4FEE;&#x6539;&#x5DF2;&#x6DFB;&#x52A0;&#x7684; Android.bp &#x6587;&#x4EF6;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="json" class="language-json">android_app <span class="token punctuation">{</span>
    name<span class="token operator">:</span> <span class="token string">&quot;FirstSystemApp&quot;</span><span class="token punctuation">,</span>

    srcs<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;src/**/*.java&quot;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>

    resource_dirs<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;res&quot;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>

    manifest<span class="token operator">:</span> <span class="token string">&quot;AndroidManifest.xml&quot;</span><span class="token punctuation">,</span>

    platform_apis<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
    
    sdk_version<span class="token operator">:</span> <span class="token string">&quot;&quot;</span><span class="token punctuation">,</span>

    certificate<span class="token operator">:</span> <span class="token string">&quot;platform&quot;</span><span class="token punctuation">,</span>

    product_specific<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>

    <span class="token comment">//&#x4F9D;&#x8D56;</span>
    static_libs<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;androidx.appcompat_appcompat&quot;</span><span class="token punctuation">,</span>
                 <span class="token string">&quot;com.google.android.material_material&quot;</span><span class="token punctuation">,</span>
                 <span class="token string">&quot;androidx-constraintlayout_constraintlayout&quot;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>

<span class="token punctuation">}</span>
</pre><p>&#x81F3;&#x6B64;&#x6211;&#x4EEC;&#x7684;&#x7CFB;&#x7EDF; App &#x5C31;&#x521B;&#x5EFA;&#x597D;&#x4E86;&#x3002;</p>
<p>&#x63A5;&#x7740;&#x5728;&#x6211;&#x4EEC;&#x7684; Product &#x4E2D;&#x6DFB;&#x52A0;&#x8FD9;&#x4E2A;App&#xFF0C;&#x4FEE;&#x6539; <code>device/Jelly/Rice14/Rice14.mk</code>&#xFF1A;</p>
<pre data-role="codeBlock" data-info="Makefile" class="language-makefile"><span class="token comment"># &#x6DFB;&#x52A0;&#x4EE5;&#x4E0B;&#x5185;&#x5BB9;</span>
PRODUCT_PACKAGES <span class="token operator">+=</span> FirstSystemApp
</pre><p>&#x63A5;&#x7740;&#x7F16;&#x8BD1;&#x7CFB;&#x7EDF;&#xFF0C;&#x542F;&#x52A8;&#x865A;&#x62DF;&#x673A;&#xFF0C;&#x6253;&#x5F00; app&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token builtin class-name">source</span> build/envsetup.sh
lunch Rice14-eng
<span class="token function">make</span> -j16
emulator 
</pre><p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230227135955.png" alt></p>
<h3 class="mume-header" id="2-%E7%B3%BB%E7%BB%9F-app-%E4%B8%8E-%E6%99%AE%E9%80%9A-app-%E7%9A%84%E5%B7%AE%E5%BC%82">2. &#x7CFB;&#x7EDF; App &#x4E0E; &#x666E;&#x901A; App &#x7684;&#x5DEE;&#x5F02;</h3>

<h4 class="mume-header" id="21-%E7%B3%BB%E7%BB%9F-app-%E5%8F%AF%E4%BB%A5%E4%BD%BF%E7%94%A8%E6%9B%B4%E5%A4%9A%E7%9A%84-api">2.1 &#x7CFB;&#x7EDF; App &#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x66F4;&#x591A;&#x7684; api</h4>

<p>&#x5F53;&#x6211;&#x4EEC;&#x5728; Android.bp &#x4E2D;&#x914D;&#x7F6E;&#x4E86;&#xFF1A;</p>
<pre data-role="codeBlock" data-info class="language-"><code>platform_apis: true,
sdk_version: &quot;&quot;,
</code></pre><p>&#x5F53; platform_apis &#x4E3A; true &#x65F6;&#xFF0C;sdk_version &#x5FC5;&#x987B;&#x4E3A;&#x7A7A;&#x3002;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x4E0B;&#x6211;&#x4EEC;&#x7684; app &#x4F1A;&#x4F7F;&#x7528;&#x5E73;&#x53F0; API &#x8FDB;&#x884C;&#x7F16;&#x8BD1;&#x800C;&#x4E0D;&#x662F; SDK&#xFF0C;&#x8FD9;&#x6837;&#x6211;&#x4EEC;&#x7684; App &#x5C31;&#x80FD;&#x8BBF;&#x95EE;&#x5230;&#x975E; SDK API &#x4E86;&#x3002;&#x5173;&#x4E8E; SDK API &#x548C;&#x975E; SDK API &#x7684;&#x5185;&#x5BB9;&#x53EF;&#x4EE5;&#x53C2;&#x8003;<a href="https://developer.android.com/guide/app-compatibility/restrictions-non-sdk-interfaces?hl=zh-cn">&#x5B98;&#x65B9;&#x6587;&#x6863;</a></p>
<h4 class="mume-header" id="22-%E7%B3%BB%E7%BB%9F-app-%E7%9A%84%E7%AD%BE%E5%90%8D">2.2 &#x7CFB;&#x7EDF; App &#x7684;&#x7B7E;&#x540D;</h4>

<p>AOSP &#x5185;&#x7F6E;&#x4E86; apk &#x7B7E;&#x540D;&#x6587;&#x4EF6;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x5728; Android.bp &#x4E2D;&#x901A;&#x8FC7; certificate &#x914D;&#x7F6E;&#x7CFB;&#x7EDF; app &#x7684;&#x7B7E;&#x540D;&#x6587;&#x4EF6;&#xFF0C;certificate &#x7684;&#x503C;&#x4E3B;&#x8981;&#x6709;&#x4E00;&#x4E0B;&#x51E0;&#x4E2A;&#x9009;&#x9879;&#xFF1A;</p>
<ul>
<li>testkey&#xFF1A;&#x666E;&#x901A; apk&#xFF0C;&#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x4E0B;&#x4F7F;&#x7528;</li>
<li>platform&#xFF1A;&#x8BE5; apk &#x5B8C;&#x6210;&#x4E00;&#x4E9B;&#x7CFB;&#x7EDF;&#x7684;&#x6838;&#x5FC3;&#x529F;&#x80FD;&#x3002;&#x7ECF;&#x8FC7;&#x5BF9;&#x7CFB;&#x7EDF;&#x4E2D;&#x5B58;&#x5728;&#x7684;&#x6587;&#x4EF6;&#x5939;&#x7684;&#x8BBF;&#x95EE;&#x6D4B;&#x8BD5;&#xFF0C;&#x8FD9;&#x79CD;&#x65B9;&#x5F0F;&#x7F16;&#x8BD1;&#x51FA;&#x6765;&#x7684; APK &#x6240;&#x5728;&#x8FDB;&#x7A0B;&#x7684; UID &#x4E3A;system</li>
<li>shared&#xFF1A;&#x8BE5; apk &#x9700;&#x8981;&#x548C; home/contacts &#x8FDB;&#x7A0B;&#x5171;&#x4EAB;&#x6570;&#x636E;</li>
<li>media&#xFF1A;&#x8BE5; apk &#x662F; media/download &#x7CFB;&#x7EDF;&#x4E2D;&#x7684;&#x4E00;&#x73AF;</li>
<li>PRESIGNED&#xFF1A;&#x8868;&#x793A; &#x8FD9;&#x4E2A; apk &#x5DF2;&#x7ECF;&#x7B7E;&#x8FC7;&#x540D;&#x4E86;&#xFF0C;&#x7CFB;&#x7EDF;&#x4E0D;&#x9700;&#x8981;&#x518D;&#x6B21;&#x7B7E;&#x540D;;</li>
</ul>
<h4 class="mume-header" id="23-%E7%B3%BB%E7%BB%9F-app-%E8%83%BD%E4%BD%BF%E7%94%A8%E6%9B%B4%E5%A4%9A%E7%9A%84%E6%9D%83%E9%99%90">2.3 &#x7CFB;&#x7EDF; App &#x80FD;&#x4F7F;&#x7528;&#x66F4;&#x591A;&#x7684;&#x6743;&#x9650;</h4>

<p>&#x5F53; Android.bp &#x4E2D;&#x7684; privileged &#x88AB;&#x914D;&#x7F6E;&#x4E3A; true &#x65F6;&#xFF0C;&#x6211;&#x4EEC;&#x7684;&#x7CFB;&#x7EDF; App &#x5728;&#x6DFB;&#x52A0;&#x7279;&#x8BB8;&#x6743;&#x9650;&#x8BB8;&#x53EF;&#x540D;&#x5355;&#x540E;&#xFF0C;&#x80FD;&#x4F7F;&#x7528; signatureOrSystem &#x7EA7;&#x522B;&#x7684;&#x6743;&#x9650;&#xFF0C;&#x800C;&#x666E;&#x901A; App &#x662F;&#x4E0D;&#x80FD;&#x4F7F;&#x7528;&#x8FD9;&#x4E9B;&#x6743;&#x9650;&#x7684;&#x3002;</p>
<h4 class="mume-header" id="24-%E7%B3%BB%E7%BB%9F-app-%E8%83%BD%E6%9B%B4%E8%BD%BB%E6%9D%BE%E5%9C%B0%E5%AE%9E%E7%8E%B0%E8%BF%9B%E7%A8%8B%E4%BF%9D%E6%B4%BB">2.4 &#x7CFB;&#x7EDF; App &#x80FD;&#x66F4;&#x8F7B;&#x677E;&#x5730;&#x5B9E;&#x73B0;&#x8FDB;&#x7A0B;&#x4FDD;&#x6D3B;</h4>

<p>&#x4E09;&#x65B9; App &#x4E3A;&#x4E86;&#x4E0D;&#x88AB;&#x6740;&#x6389;&#xFF0C;&#x53EF;&#x4EE5;&#x8BF4;&#x662F;&#x7528;&#x5C3D;&#x4E86;&#x5343;&#x65B9;&#x767E;&#x8BA1;&#x3002;&#x4FDD;&#x6D3B;&#x5BF9;&#x4E8E;&#x7CFB;&#x7EDF; App &#x5176;&#x5B9E;&#x662F;&#x975E;&#x5E38;&#x7B80;&#x5355;&#x7684;&#xFF1A;</p>
<p>&#x5728; AndroidManifest.xml &#x4E2D;&#x6DFB;&#x52A0;&#x5982;&#x4E0B;&#x53C2;&#x6570;&#x5373;&#x53EF;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="xml" class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>application</span>
    <span class="token attr-name"><span class="token namespace">android:</span>persistent</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>true<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
</pre><h3 class="mume-header" id="3-%E7%B3%BB%E7%BB%9F-app-%E6%B7%BB%E5%8A%A0%E4%BE%9D%E8%B5%96">3. &#x7CFB;&#x7EDF; App &#x6DFB;&#x52A0;&#x4F9D;&#x8D56;</h3>

<h4 class="mume-header" id="31-%E6%B7%BB%E5%8A%A0-aosp-%E4%B8%AD%E5%B7%B2%E6%9C%89%E7%9A%84%E5%BA%93">3.1 &#x6DFB;&#x52A0; AOSP &#x4E2D;&#x5DF2;&#x6709;&#x7684;&#x5E93;</h4>

<p>&#x5728; FirstSystemApp &#x7684; Android.bp &#x4E2D;&#x6211;&#x4EEC;&#x6DFB;&#x52A0;&#x4E86;&#x5F88;&#x591A;&#x4F9D;&#x8D56;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="json" class="language-json">    static_libs<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;androidx.appcompat_appcompat&quot;</span><span class="token punctuation">,</span>
                 <span class="token string">&quot;com.google.android.material_material&quot;</span><span class="token punctuation">,</span>
                 <span class="token string">&quot;androidx-constraintlayout_constraintlayout&quot;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>

</pre><p>&#x5728; AOSP &#x4E2D;&#xFF0C; &#x5F88;&#x591A;&#x5E38;&#x7528;&#x7684;&#x5E93;&#x5747;&#x4EE5;&#x9884;&#x7F16;&#x8BD1;&#x6A21;&#x5757;&#x7684;&#x65B9;&#x5F0F;&#x6DFB;&#x52A0;&#x5230;&#x7CFB;&#x7EDF;&#x6E90;&#x7801;&#x4E2D;&#x3002;&#x6BD4;&#x5982;&#x5E38;&#x7528;&#x7684; AndroidX &#x5E93;&#x5B9A;&#x4E49;&#x5728; <code>prebuilts/sdk/current/androidx</code> &#x76EE;&#x5F55;&#x4E0B;&#x3002;&#x8FD9;&#x4E9B;&#x5E93;&#x901A;&#x8FC7; <code>prebuilts/sdk/current/androidx/Android.bp</code> &#x5F15;&#x5165;&#x3002;&#x6BD4;&#x5982; recyclerview &#x5E93;&#x7684;&#x5F15;&#x5165;&#x65B9;&#x5F0F;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="json" class="language-json">android_library <span class="token punctuation">{</span>
    name<span class="token operator">:</span> <span class="token string">&quot;androidx.recyclerview_recyclerview&quot;</span><span class="token punctuation">,</span>
    sdk_version<span class="token operator">:</span> <span class="token string">&quot;31&quot;</span><span class="token punctuation">,</span>
    apex_available<span class="token operator">:</span> <span class="token punctuation">[</span>
        <span class="token string">&quot;//apex_available:platform&quot;</span><span class="token punctuation">,</span>
        <span class="token string">&quot;//apex_available:anyapex&quot;</span><span class="token punctuation">,</span>
    <span class="token punctuation">]</span><span class="token punctuation">,</span>
    min_sdk_version<span class="token operator">:</span> <span class="token string">&quot;14&quot;</span><span class="token punctuation">,</span>
    manifest<span class="token operator">:</span> <span class="token string">&quot;manifests/androidx.recyclerview_recyclerview/AndroidManifest.xml&quot;</span><span class="token punctuation">,</span>
    static_libs<span class="token operator">:</span> <span class="token punctuation">[</span>
        <span class="token string">&quot;androidx.recyclerview_recyclerview-nodeps&quot;</span><span class="token punctuation">,</span>
        <span class="token string">&quot;androidx.annotation_annotation&quot;</span><span class="token punctuation">,</span>
        <span class="token string">&quot;androidx.collection_collection&quot;</span><span class="token punctuation">,</span>
        <span class="token string">&quot;androidx.core_core&quot;</span><span class="token punctuation">,</span>
        <span class="token string">&quot;androidx.customview_customview&quot;</span><span class="token punctuation">,</span>
    <span class="token punctuation">]</span><span class="token punctuation">,</span>
    java_version<span class="token operator">:</span> <span class="token string">&quot;1.7&quot;</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span>
</pre><p>&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x5F15;&#x5165;&#x7684;&#x662F;&#x4E00;&#x4E2A; <code>android_library</code>&#xFF0C;&#x540D;&#x5B57;&#x53EB; <code>androidx.recyclerview_recyclerview</code>&#x3002;maifest &#x6587;&#x4EF6;&#x5728; <code>manifests/androidx.recyclerview_recyclerview/</code> &#x76EE;&#x5F55;&#x4E0B;&#xFF0C;&#x8FDB;&#x5165;&#x8FD9;&#x4E2A;&#x76EE;&#x5F55;&#x53EA;&#x6709;&#x4E00;&#x4E2A; <code>AndroidManifest.xml</code> &#x6587;&#x4EF6;&#xFF0C;&#x5176;&#x5185;&#x5BB9;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="xml" class="language-xml"><span class="token prolog">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;</span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>manifest</span> <span class="token attr-name"><span class="token namespace">xmlns:</span>android</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://schemas.android.com/apk/res/android<span class="token punctuation">&quot;</span></span>
    <span class="token attr-name">package</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>androidx.recyclerview<span class="token punctuation">&quot;</span></span> <span class="token punctuation">&gt;</span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>uses-sdk</span>
        <span class="token attr-name"><span class="token namespace">android:</span>minSdkVersion</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>14<span class="token punctuation">&quot;</span></span>
        <span class="token attr-name"><span class="token namespace">android:</span>targetSdkVersion</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>28<span class="token punctuation">&quot;</span></span> <span class="token punctuation">/&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>manifest</span><span class="token punctuation">&gt;</span></span>
</pre><p>&#x5F88;&#x5947;&#x602A;&#xFF0C;&#x5E76;&#x6CA1;&#x6709;&#x770B;&#x5230; RecyclerView &#x5E93;&#x7684;&#x6E90;&#x7801;&#xFF0C;&#x4E5F;&#x6CA1;&#x6709;&#x770B;&#x5230; aar &#x5E93;&#x6587;&#x4EF6;&#x3002;&#x6211;&#x4EEC;&#x63A5;&#x7740;&#x770B; Android.bp &#x4E2D;&#x7684;&#x4F9D;&#x8D56;&#xFF0C;&#x5176;&#x4E2D;&#x4E00;&#x9879;&#x662F; <code>androidx.recyclerview_recyclerview-nodeps</code>&#xFF0C;&#x6211;&#x4EEC;&#x5728; <code>Android.bp</code> &#x4E2D;&#x770B;&#x4E00;&#x4E0B;&#x5B83;&#x7684;&#x5F15;&#x5165;&#x65B9;&#x5F0F;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="json" class="language-json">android_library_import <span class="token punctuation">{</span>
    name<span class="token operator">:</span> <span class="token string">&quot;androidx.recyclerview_recyclerview-nodeps&quot;</span><span class="token punctuation">,</span>
    aars<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;m2repository/androidx/recyclerview/recyclerview/1.1.0-alpha07/recyclerview-1.1.0-alpha07.aar&quot;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
    sdk_version<span class="token operator">:</span> <span class="token string">&quot;current&quot;</span><span class="token punctuation">,</span>
    min_sdk_version<span class="token operator">:</span> <span class="token string">&quot;14&quot;</span><span class="token punctuation">,</span>
    static_libs<span class="token operator">:</span> <span class="token punctuation">[</span>
        <span class="token string">&quot;androidx.annotation_annotation&quot;</span><span class="token punctuation">,</span>
        <span class="token string">&quot;androidx.collection_collection&quot;</span><span class="token punctuation">,</span>
        <span class="token string">&quot;androidx.core_core&quot;</span><span class="token punctuation">,</span>
        <span class="token string">&quot;androidx.customview_customview&quot;</span><span class="token punctuation">,</span>
    <span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span>
</pre><p>&#x8FD9;&#x91CC;&#x770B;&#x5230;&#x4E86;&#xFF0C;&#x5B83;&#x7684; aar &#x5E93;&#x5728;&#x8FD9;&#x91CC;&#xFF1A; <code>m2repository/androidx/recyclerview/recyclerview/1.1.0-alpha07/recyclerview-1.1.0-alpha07.aar</code></p>
<p>&#x7EE7;&#x7EED;&#x67E5;&#x9605;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x53D1;&#x73B0;&#xFF0C;<code>prebuilts/tools/common/m2</code> &#x76EE;&#x5F55;&#x4E0B;&#x5F15;&#x5165;&#x4E86;&#x5927;&#x91CF;&#x7684;&#x4E09;&#x65B9;&#x5E93;&#x3002;</p>
<p>&#x603B;&#x7ED3;&#x4E00;&#x4E0B;&#xFF0C;&#x5F53;&#x6211;&#x4EEC;&#x7684;&#x7CFB;&#x7EDF; App &#x9700;&#x8981;&#x5F15;&#x5165;&#x4E00;&#x4E2A;&#x5E93;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x901A;&#x5E38;&#x4F1A;&#x5728; prebuilds &#x76EE;&#x5F55;&#x4E0B;&#x67E5;&#x627E;&#xFF1A;</p>
<ul>
<li>androidx &#x76F8;&#x5173;&#x5E93;&#x5F15;&#x5165;&#xFF0C;&#x5148;&#x5728; prebuilts/sdk/current/androidx &#x4E0B;&#x5BFB;&#x627E;&#x914D;&#x7F6E;&#x597D;&#x7684; bp &#x6587;&#x4EF6;</li>
<li>&#x5176;&#x4ED6;&#x5E93;&#x5F15;&#x5165;&#xFF0C;&#x5148;&#x5728; prebuilts/tools/common/m2 &#x4E0B;&#x5BFB;&#x627E;&#x5BFB;&#x627E;&#x914D;&#x7F6E;&#x597D;&#x7684; bp &#x6587;&#x4EF6;</li>
</ul>
<p>&#x90FD;&#x6CA1;&#x6709;&#xFF0C;&#x5C31;&#x5F97;&#x81EA;&#x5DF1;&#x5F15;&#x5165;&#x4E86;</p>
<h4 class="mume-header" id="32-%E8%87%AA%E5%B7%B1%E7%BB%99-aosp-%E6%B7%BB%E5%8A%A0%E5%BA%93">3.2 &#x81EA;&#x5DF1;&#x7ED9; AOSP &#x6DFB;&#x52A0;&#x5E93;</h4>

<h5 class="mume-header" id="321-java-%E5%BA%93%E6%BA%90%E7%A0%81%E5%BC%95%E5%85%A5">3.2.1 java &#x5E93;&#x6E90;&#x7801;&#x5F15;&#x5165;</h5>

<p>&#x8FD9;&#x90E8;&#x5206;&#x53C2;&#x8003;&#x4E4B;&#x524D;&#x7684; &#x6DFB;&#x52A0; C/C++&#x3001;Java &#x5E93;</p>
<h5 class="mume-header" id="322-java-%E5%BA%93%E4%BB%A5-jar-%E5%8C%85%E5%BD%A2%E5%BC%8F%E5%BC%95%E5%85%A5">3.2.2 java &#x5E93;&#x4EE5; jar &#x5305;&#x5F62;&#x5F0F;&#x5F15;&#x5165;</h5>

<p>&#x8FD9;&#x90E8;&#x5206;&#x53C2;&#x8003;&#x4E4B;&#x524D;&#x7684;&#x6DFB;&#x52A0; C/C++&#x3001;Java &#x5E93;</p>
<h5 class="mume-header" id="323-android-%E5%BA%93%E6%BA%90%E7%A0%81%E5%BC%95%E5%85%A5">3.2.3 Android &#x5E93;&#x6E90;&#x7801;&#x5F15;&#x5165;</h5>

<p>&#x5728; <code>device/Jelly/Rice14</code> &#x76EE;&#x5F55;&#x4E0B;&#x521B;&#x5EFA;&#x5982;&#x4E0B;&#x7684;&#x6587;&#x4EF6;&#x548C;&#x6587;&#x4EF6;&#x5939;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230228155617.png" alt></p>
<p>&#x5176;&#x4E2D; <code>MyCustomView.java</code> &#x662F;&#x4E00;&#x4E2A;&#x7528;&#x4E8E;&#x6F14;&#x793A;&#x7684;&#x6CA1;&#x6709;&#x5177;&#x4F53;&#x529F;&#x80FD;&#x7684;&#x81EA;&#x5B9A;&#x4E49; View&#xFF1A;</p>
<pre data-role="codeBlock" data-info="java" class="language-java"><span class="token keyword keyword-package">package</span> <span class="token namespace">com<span class="token punctuation">.</span>yuandaima<span class="token punctuation">.</span>firstsystemandroidlibrary</span><span class="token punctuation">;</span>

<span class="token keyword keyword-import">import</span> <span class="token namespace">android<span class="token punctuation">.</span>content<span class="token punctuation">.</span></span><span class="token class-name">Context</span><span class="token punctuation">;</span>
<span class="token keyword keyword-import">import</span> <span class="token namespace">android<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">AttributeSet</span><span class="token punctuation">;</span>
<span class="token keyword keyword-import">import</span> <span class="token namespace">android<span class="token punctuation">.</span>view<span class="token punctuation">.</span></span><span class="token class-name">View</span><span class="token punctuation">;</span>

<span class="token keyword keyword-import">import</span> <span class="token namespace">androidx<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">Nullable</span><span class="token punctuation">;</span>

<span class="token keyword keyword-public">public</span> <span class="token keyword keyword-class">class</span> <span class="token class-name">MyCustomView</span> <span class="token keyword keyword-extends">extends</span> <span class="token class-name">View</span> <span class="token punctuation">{</span>
    <span class="token keyword keyword-public">public</span> <span class="token class-name">MyCustomView</span><span class="token punctuation">(</span><span class="token class-name">Context</span> context<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword keyword-super">super</span><span class="token punctuation">(</span>context<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword keyword-public">public</span> <span class="token class-name">MyCustomView</span><span class="token punctuation">(</span><span class="token class-name">Context</span> context<span class="token punctuation">,</span> <span class="token annotation punctuation">@Nullable</span> <span class="token class-name">AttributeSet</span> attrs<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword keyword-super">super</span><span class="token punctuation">(</span>context<span class="token punctuation">,</span> attrs<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword keyword-public">public</span> <span class="token class-name">MyCustomView</span><span class="token punctuation">(</span><span class="token class-name">Context</span> context<span class="token punctuation">,</span> <span class="token annotation punctuation">@Nullable</span> <span class="token class-name">AttributeSet</span> attrs<span class="token punctuation">,</span> <span class="token keyword keyword-int">int</span> defStyleAttr<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword keyword-super">super</span><span class="token punctuation">(</span>context<span class="token punctuation">,</span> attrs<span class="token punctuation">,</span> defStyleAttr<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword keyword-public">public</span> <span class="token class-name">MyCustomView</span><span class="token punctuation">(</span><span class="token class-name">Context</span> context<span class="token punctuation">,</span> <span class="token annotation punctuation">@Nullable</span> <span class="token class-name">AttributeSet</span> attrs<span class="token punctuation">,</span> <span class="token keyword keyword-int">int</span> defStyleAttr<span class="token punctuation">,</span> <span class="token keyword keyword-int">int</span> defStyleRes<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword keyword-super">super</span><span class="token punctuation">(</span>context<span class="token punctuation">,</span> attrs<span class="token punctuation">,</span> defStyleAttr<span class="token punctuation">,</span> defStyleRes<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</pre><p><code>AndroidManifest.xml</code> &#x7684;&#x5185;&#x5BB9;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="xml" class="language-xml"><span class="token prolog">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>manifest</span> <span class="token attr-name"><span class="token namespace">xmlns:</span>android</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://schemas.android.com/apk/res/android<span class="token punctuation">&quot;</span></span>
 <span class="token attr-name">package</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>com.yuandaima.firstsystemandroidlibrary<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>manifest</span><span class="token punctuation">&gt;</span></span>
</pre><p><code>Android.bp</code> &#x7684;&#x5185;&#x5BB9;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="json" class="language-json">android_library  <span class="token punctuation">{</span>
    name<span class="token operator">:</span> <span class="token string">&quot;FirstSystemAndroidLibrary&quot;</span><span class="token punctuation">,</span>

    srcs<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;src/**/*.java&quot;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>

    resource_dirs<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;res&quot;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>

    manifest<span class="token operator">:</span> <span class="token string">&quot;AndroidManifest.xml&quot;</span><span class="token punctuation">,</span>

    sdk_version<span class="token operator">:</span> <span class="token string">&quot;current&quot;</span><span class="token punctuation">,</span>

    product_specific<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
    
    <span class="token comment">//&#x4F9D;&#x8D56;</span>
    static_libs<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;androidx.appcompat_appcompat&quot;</span><span class="token punctuation">,</span><span class="token punctuation">]</span><span class="token punctuation">,</span>

    java_version<span class="token operator">:</span> <span class="token string">&quot;1.7&quot;</span><span class="token punctuation">,</span>

    installable<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>

<span class="token punctuation">}</span>
</pre><p>&#x63A5;&#x7740;&#x4FEE;&#x6539;&#x6211;&#x4EEC;&#x7684; FirstSystemApp &#x9879;&#x76EE;</p>
<p><code>Android.bp</code> &#x6DFB;&#x52A0;&#x4F9D;&#x8D56;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="json" class="language-json">android_library  <span class="token punctuation">{</span>

    <span class="token comment">//......</span>
    
    <span class="token comment">//&#x4F9D;&#x8D56;</span>
    static_libs<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;androidx.appcompat_appcompat&quot;</span><span class="token punctuation">,</span>
                 <span class="token string">&quot;com.google.android.material_material&quot;</span><span class="token punctuation">,</span>
                 <span class="token string">&quot;androidx-constraintlayout_constraintlayout&quot;</span><span class="token punctuation">,</span>
                 <span class="token string">&quot;FirstSystemAndroidLibrary&quot;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>

<span class="token punctuation">}</span>
</pre><p>&#x4FEE;&#x6539;&#x4E00;&#x4E0B; <code>MainActivity</code>&#xFF0C;&#x5728; App &#x91CC;&#x4F7F;&#x7528;&#x6211;&#x4EEC;&#x7684;&#x81EA;&#x5B9A;&#x4E49; View&#xFF1A;</p>
<pre data-role="codeBlock" data-info="java" class="language-java"><span class="token keyword keyword-package">package</span> <span class="token namespace">com<span class="token punctuation">.</span>yuandaima<span class="token punctuation">.</span>firstsystemapp</span><span class="token punctuation">;</span>

<span class="token keyword keyword-import">import</span> <span class="token namespace">androidx<span class="token punctuation">.</span>appcompat<span class="token punctuation">.</span>app<span class="token punctuation">.</span></span><span class="token class-name">AppCompatActivity</span><span class="token punctuation">;</span>

<span class="token keyword keyword-import">import</span> <span class="token namespace">android<span class="token punctuation">.</span>os<span class="token punctuation">.</span></span><span class="token class-name">Bundle</span><span class="token punctuation">;</span>

<span class="token keyword keyword-import">import</span> <span class="token namespace">com<span class="token punctuation">.</span>yuandaima<span class="token punctuation">.</span>firstsystemandroidlibrary<span class="token punctuation">.</span></span><span class="token class-name">MyCustomView</span><span class="token punctuation">;</span>

<span class="token keyword keyword-public">public</span> <span class="token keyword keyword-class">class</span> <span class="token class-name">MainActivity</span> <span class="token keyword keyword-extends">extends</span> <span class="token class-name">AppCompatActivity</span> <span class="token punctuation">{</span>

    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword keyword-protected">protected</span> <span class="token keyword keyword-void">void</span> <span class="token function">onCreate</span><span class="token punctuation">(</span><span class="token class-name">Bundle</span> savedInstanceState<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword keyword-super">super</span><span class="token punctuation">.</span><span class="token function">onCreate</span><span class="token punctuation">(</span>savedInstanceState<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token function">setContentView</span><span class="token punctuation">(</span><span class="token class-name">R</span><span class="token punctuation">.</span>layout<span class="token punctuation">.</span>activity_main<span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token class-name">MyCustomView</span> myView <span class="token operator">=</span> <span class="token keyword keyword-new">new</span> <span class="token class-name">MyCustomView</span><span class="token punctuation">(</span><span class="token keyword keyword-this">this</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</pre><p>&#x63A5;&#x7740;&#x7F16;&#x8BD1;&#x7CFB;&#x7EDF;&#xFF0C;&#x542F;&#x52A8;&#x865A;&#x62DF;&#x673A;&#xFF0C;&#x6253;&#x5F00; app&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token builtin class-name">source</span> build/envsetup.sh
lunch Rice14-eng
<span class="token function">make</span> -j16
emulator 
</pre><p>&#x8FD9;&#x6837;&#x6211;&#x4EEC;&#x7684;&#x5E93;&#x5C31;&#x7B97;&#x5F15;&#x5165;&#x5B8C;&#x6BD5;&#x4E86;&#x3002;</p>
<h5 class="mume-header" id="324-android-%E5%BA%93%E4%BB%A5-aar-%E5%8C%85%E5%BD%A2%E5%BC%8F%E5%BC%95%E5%85%A5">3.2.4 Android &#x5E93;&#x4EE5; aar &#x5305;&#x5F62;&#x5F0F;&#x5F15;&#x5165;</h5>

<p>&#x66F4;&#x591A;&#x7684;&#x65F6;&#x5019; Android &#x5E93;&#x662F;&#x4EE5; aar &#x5305;&#x7684;&#x5F62;&#x5F0F;&#x5F15;&#x5165;&#x3002;</p>
<p>&#x5047;&#x8BBE;&#x6211;&#x4EEC;&#x7684; FirstSystemApp &#x9700;&#x8981;&#x5F15;&#x5165; lottie &#x8FD9;&#x4E2A;&#x52A8;&#x753B;&#x5E93;&#x3002;</p>
<p>&#x9996;&#x5148;&#x6211;&#x4EEC;<a href="https://repo1.maven.org/maven2/com/airbnb/android/lottie/5.2.0/">&#x8FD9;&#x91CC;</a>&#x4E0B;&#x8F7D;&#x597D; lottie &#x5E93;&#x7684; aar &#x6253;&#x5305;&#x6587;&#x4EF6;&#x3002;</p>
<p>&#x5728; <code>device/Jelly/Rice14</code> &#x76EE;&#x5F55;&#x4E0B;&#x521B;&#x5EFA;&#x5982;&#x4E0B;&#x7684;&#x76EE;&#x5F55;&#x7ED3;&#x6784;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">liblottie/
&#x251C;&#x2500;&#x2500; Android.bp
&#x2514;&#x2500;&#x2500; lottie-5.2.0.aar
</pre><p>&#x5176;&#x4E2D; Android.bp &#x7684;&#x5185;&#x5BB9;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">android_library_import <span class="token punctuation">{</span>
    name: <span class="token string">&quot;lib-lottie&quot;</span>,
    aars: <span class="token punctuation">[</span><span class="token string">&quot;lottie-5.2.0.aar&quot;</span><span class="token punctuation">]</span>,
    sdk_version: <span class="token string">&quot;current&quot;</span>,
<span class="token punctuation">}</span>
</pre><p>&#x7136;&#x540E;&#x6211;&#x4EEC;&#x4FEE;&#x6539; FirstSystemApp &#x4E2D;&#x7684; Android.bp &#x5F15;&#x5165;&#x8FD9;&#x4E2A;&#x5E93;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="json" class="language-json">    static_libs<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;androidx.appcompat_appcompat&quot;</span><span class="token punctuation">,</span>
                 <span class="token string">&quot;com.google.android.material_material&quot;</span><span class="token punctuation">,</span>
                 <span class="token string">&quot;androidx-constraintlayout_constraintlayout&quot;</span><span class="token punctuation">,</span>
                 <span class="token string">&quot;FirstSystemAndroidLibrary&quot;</span><span class="token punctuation">,</span>
                  <span class="token string">&quot;lib-lottie&quot;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
</pre><p>&#x8FD9;&#x6837;&#x5C31;&#x53EF;&#x4EE5;&#x5728; App &#x4E2D;&#x4F7F;&#x7528; lottie &#x5E93;&#x4E86;</p>
<h3 class="mume-header" id="4-jni-%E9%A1%B9%E7%9B%AE">4. JNI &#x9879;&#x76EE;</h3>

<h4 class="mume-header" id="41-%E5%88%9B%E5%BB%BA-jni-%E9%A1%B9%E7%9B%AE">4.1 &#x521B;&#x5EFA; JNI &#x9879;&#x76EE;</h4>

<p>Android 10 &#x4E0B;&#xFF0C;Android.bp(soong) &#x65B9;&#x5F0F;&#x5BF9; JNI &#x7684;&#x652F;&#x6301;&#x6709;&#x70B9;&#x95EE;&#x9898;&#xFF0C;&#x6240;&#x4EE5;&#x6211;&#x4EEC;&#x53EA;&#x6709;&#x7528; <a href="http://Android.mk">Android.mk</a> &#x6765;&#x6F14;&#x793A;&#x4E86;&#x3002;Android 13 &#x4E0B; Android.bp (soong) &#x662F;&#x5B8C;&#x7F8E;&#x652F;&#x6301; JNI &#x7684;&#x3002;</p>
<p>&#x5728; <code>device/Jelly/Rice14</code> &#x76EE;&#x5F55;&#x4E0B;&#x6DFB;&#x52A0;&#x5982;&#x4E0B;&#x7684;&#x6587;&#x4EF6;&#x4E0E;&#x6587;&#x4EF6;&#x5939;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230306191505.png" alt></p>
<p>jni/Android.mk &#x5185;&#x5BB9;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="Makefile" class="language-makefile">LOCAL_PATH<span class="token operator">:=</span> <span class="token variable">$</span><span class="token punctuation">(</span><span class="token keyword keyword-call">call</span> my-dir<span class="token punctuation">)</span>
<span class="token keyword keyword-include">include</span> <span class="token variable">$</span><span class="token punctuation">(</span>CLEAR_VARS<span class="token punctuation">)</span>

LOCAL_MODULE_TAGS <span class="token operator">:=</span> optional

<span class="token comment"># This is the target being built.</span>
LOCAL_MODULE<span class="token operator">:=</span> myjnilib


<span class="token comment"># All of the source files that we will compile.</span>
LOCAL_SRC_FILES<span class="token operator">:=</span> \
    native.cpp

<span class="token comment"># All of the shared libraries we link against.</span>
LOCAL_LDLIBS <span class="token operator">:=</span> -llog

<span class="token comment"># No static libraries.</span>
LOCAL_STATIC_LIBRARIES <span class="token operator">:=</span>

LOCAL_CFLAGS <span class="token operator">:=</span> -Wall -Werror

LOCAL_NDK_STL_VARIANT <span class="token operator">:=</span> none

LOCAL_SDK_VERSION <span class="token operator">:=</span> current

LOCAL_PRODUCT_MODULE <span class="token operator">:=</span> true

<span class="token keyword keyword-include">include</span> <span class="token variable">$</span><span class="token punctuation">(</span>BUILD_SHARED_LIBRARY<span class="token punctuation">)</span>

</pre><p>jni/native.cpp &#x7684;&#x5185;&#x5BB9;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="c++" class="language-cpp"><span class="token comment">/*
 * Copyright (C) 2008 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */</span>

<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">define</span> <span class="token macro-name">LOG_TAG</span> <span class="token string">&quot;simplejni native.cpp&quot;</span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;android/log.h&gt;</span></span>

<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;stdio.h&gt;</span></span>

<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&quot;jni.h&quot;</span></span>

<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">define</span> <span class="token macro-name function">ALOGV</span><span class="token expression"><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span> <span class="token function">__android_log_print</span><span class="token punctuation">(</span>ANDROID_LOG_VERBOSE<span class="token punctuation">,</span> LOG_TAG<span class="token punctuation">,</span> __VA_ARGS__<span class="token punctuation">)</span></span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">define</span> <span class="token macro-name function">ALOGD</span><span class="token expression"><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span> <span class="token function">__android_log_print</span><span class="token punctuation">(</span>ANDROID_LOG_DEBUG<span class="token punctuation">,</span> LOG_TAG<span class="token punctuation">,</span> __VA_ARGS__<span class="token punctuation">)</span></span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">define</span> <span class="token macro-name function">ALOGI</span><span class="token expression"><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span> <span class="token function">__android_log_print</span><span class="token punctuation">(</span>ANDROID_LOG_INFO<span class="token punctuation">,</span> LOG_TAG<span class="token punctuation">,</span> __VA_ARGS__<span class="token punctuation">)</span></span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">define</span> <span class="token macro-name function">ALOGW</span><span class="token expression"><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span> <span class="token function">__android_log_print</span><span class="token punctuation">(</span>ANDROID_LOG_WARN<span class="token punctuation">,</span> LOG_TAG<span class="token punctuation">,</span> __VA_ARGS__<span class="token punctuation">)</span></span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">define</span> <span class="token macro-name function">ALOGE</span><span class="token expression"><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span> <span class="token function">__android_log_print</span><span class="token punctuation">(</span>ANDROID_LOG_ERROR<span class="token punctuation">,</span> LOG_TAG<span class="token punctuation">,</span> __VA_ARGS__<span class="token punctuation">)</span></span></span>

<span class="token keyword keyword-static">static</span> jint
<span class="token function">add</span><span class="token punctuation">(</span>JNIEnv<span class="token operator">*</span> <span class="token comment">/*env*/</span><span class="token punctuation">,</span> jobject <span class="token comment">/*thiz*/</span><span class="token punctuation">,</span> jint a<span class="token punctuation">,</span> jint b<span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword keyword-int">int</span> result <span class="token operator">=</span> a <span class="token operator">+</span> b<span class="token punctuation">;</span>
    <span class="token function">ALOGI</span><span class="token punctuation">(</span><span class="token string">&quot;%d + %d = %d&quot;</span><span class="token punctuation">,</span> a<span class="token punctuation">,</span> b<span class="token punctuation">,</span> result<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword keyword-return">return</span> result<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword keyword-static">static</span> <span class="token keyword keyword-const">const</span> <span class="token keyword keyword-char">char</span> <span class="token operator">*</span>classPathName <span class="token operator">=</span> <span class="token string">&quot;com/example/android/simplejni/Native&quot;</span><span class="token punctuation">;</span>

<span class="token keyword keyword-static">static</span> JNINativeMethod methods<span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">{</span>
  <span class="token punctuation">{</span><span class="token string">&quot;add&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;(II)I&quot;</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token keyword keyword-void">void</span><span class="token operator">*</span><span class="token punctuation">)</span>add <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>

<span class="token comment">/*
 * Register several native methods for one class.
 */</span>
<span class="token keyword keyword-static">static</span> <span class="token keyword keyword-int">int</span> <span class="token function">registerNativeMethods</span><span class="token punctuation">(</span>JNIEnv<span class="token operator">*</span> env<span class="token punctuation">,</span> <span class="token keyword keyword-const">const</span> <span class="token keyword keyword-char">char</span><span class="token operator">*</span> className<span class="token punctuation">,</span>
    JNINativeMethod<span class="token operator">*</span> gMethods<span class="token punctuation">,</span> <span class="token keyword keyword-int">int</span> numMethods<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    jclass clazz<span class="token punctuation">;</span>

    clazz <span class="token operator">=</span> env<span class="token operator">-&gt;</span><span class="token function">FindClass</span><span class="token punctuation">(</span>className<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword keyword-if">if</span> <span class="token punctuation">(</span>clazz <span class="token operator">==</span> <span class="token constant">NULL</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token function">ALOGE</span><span class="token punctuation">(</span><span class="token string">&quot;Native registration unable to find class &apos;%s&apos;&quot;</span><span class="token punctuation">,</span> className<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword keyword-return">return</span> JNI_FALSE<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword keyword-if">if</span> <span class="token punctuation">(</span>env<span class="token operator">-&gt;</span><span class="token function">RegisterNatives</span><span class="token punctuation">(</span>clazz<span class="token punctuation">,</span> gMethods<span class="token punctuation">,</span> numMethods<span class="token punctuation">)</span> <span class="token operator">&lt;</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token function">ALOGE</span><span class="token punctuation">(</span><span class="token string">&quot;RegisterNatives failed for &apos;%s&apos;&quot;</span><span class="token punctuation">,</span> className<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword keyword-return">return</span> JNI_FALSE<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword keyword-return">return</span> JNI_TRUE<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token comment">/*
 * Register native methods for all classes we know about.
 *
 * returns JNI_TRUE on success.
 */</span>
<span class="token keyword keyword-static">static</span> <span class="token keyword keyword-int">int</span> <span class="token function">registerNatives</span><span class="token punctuation">(</span>JNIEnv<span class="token operator">*</span> env<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
  <span class="token keyword keyword-if">if</span> <span class="token punctuation">(</span><span class="token operator">!</span><span class="token function">registerNativeMethods</span><span class="token punctuation">(</span>env<span class="token punctuation">,</span> classPathName<span class="token punctuation">,</span>
                 methods<span class="token punctuation">,</span> <span class="token keyword keyword-sizeof">sizeof</span><span class="token punctuation">(</span>methods<span class="token punctuation">)</span> <span class="token operator">/</span> <span class="token keyword keyword-sizeof">sizeof</span><span class="token punctuation">(</span>methods<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword keyword-return">return</span> JNI_FALSE<span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  <span class="token keyword keyword-return">return</span> JNI_TRUE<span class="token punctuation">;</span>
<span class="token punctuation">}</span>


<span class="token comment">// ----------------------------------------------------------------------------</span>

<span class="token comment">/*
 * This is called by the VM when the shared library is first loaded.
 */</span>
 
<span class="token keyword keyword-typedef">typedef</span> <span class="token keyword keyword-union">union</span> <span class="token punctuation">{</span>
    JNIEnv<span class="token operator">*</span> env<span class="token punctuation">;</span>
    <span class="token keyword keyword-void">void</span><span class="token operator">*</span> venv<span class="token punctuation">;</span>
<span class="token punctuation">}</span> UnionJNIEnvToVoid<span class="token punctuation">;</span>

jint <span class="token function">JNI_OnLoad</span><span class="token punctuation">(</span>JavaVM<span class="token operator">*</span> vm<span class="token punctuation">,</span> <span class="token keyword keyword-void">void</span><span class="token operator">*</span> <span class="token comment">/*reserved*/</span><span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    UnionJNIEnvToVoid uenv<span class="token punctuation">;</span>
    uenv<span class="token punctuation">.</span>venv <span class="token operator">=</span> <span class="token constant">NULL</span><span class="token punctuation">;</span>
    jint result <span class="token operator">=</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">;</span>
    JNIEnv<span class="token operator">*</span> env <span class="token operator">=</span> <span class="token constant">NULL</span><span class="token punctuation">;</span>
    
    <span class="token function">ALOGI</span><span class="token punctuation">(</span><span class="token string">&quot;JNI_OnLoad&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword keyword-if">if</span> <span class="token punctuation">(</span>vm<span class="token operator">-&gt;</span><span class="token function">GetEnv</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>uenv<span class="token punctuation">.</span>venv<span class="token punctuation">,</span> JNI_VERSION_1_4<span class="token punctuation">)</span> <span class="token operator">!=</span> JNI_OK<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token function">ALOGE</span><span class="token punctuation">(</span><span class="token string">&quot;ERROR: GetEnv failed&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword keyword-goto">goto</span> bail<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    env <span class="token operator">=</span> uenv<span class="token punctuation">.</span>env<span class="token punctuation">;</span>

    <span class="token keyword keyword-if">if</span> <span class="token punctuation">(</span><span class="token function">registerNatives</span><span class="token punctuation">(</span>env<span class="token punctuation">)</span> <span class="token operator">!=</span> JNI_TRUE<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token function">ALOGE</span><span class="token punctuation">(</span><span class="token string">&quot;ERROR: registerNatives failed&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword keyword-goto">goto</span> bail<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    
    result <span class="token operator">=</span> JNI_VERSION_1_4<span class="token punctuation">;</span>
    
bail<span class="token operator">:</span>
    <span class="token keyword keyword-return">return</span> result<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</pre><p>SimpleJNI.java &#x7684;&#x5185;&#x5BB9;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="java" class="language-java"><span class="token keyword keyword-package">package</span> <span class="token namespace">com<span class="token punctuation">.</span>example<span class="token punctuation">.</span>android<span class="token punctuation">.</span>simplejni</span><span class="token punctuation">;</span>

<span class="token keyword keyword-import">import</span> <span class="token namespace">android<span class="token punctuation">.</span>app<span class="token punctuation">.</span></span><span class="token class-name">Activity</span><span class="token punctuation">;</span>
<span class="token keyword keyword-import">import</span> <span class="token namespace">android<span class="token punctuation">.</span>os<span class="token punctuation">.</span></span><span class="token class-name">Bundle</span><span class="token punctuation">;</span>
<span class="token keyword keyword-import">import</span> <span class="token namespace">android<span class="token punctuation">.</span>widget<span class="token punctuation">.</span></span><span class="token class-name">TextView</span><span class="token punctuation">;</span>

<span class="token keyword keyword-public">public</span> <span class="token keyword keyword-class">class</span> <span class="token class-name">SimpleJNI</span> <span class="token keyword keyword-extends">extends</span> <span class="token class-name">Activity</span> <span class="token punctuation">{</span>
    <span class="token doc-comment comment">/** Called when the activity is first created. */</span>
    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword keyword-public">public</span> <span class="token keyword keyword-void">void</span> <span class="token function">onCreate</span><span class="token punctuation">(</span><span class="token class-name">Bundle</span> savedInstanceState<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword keyword-super">super</span><span class="token punctuation">.</span><span class="token function">onCreate</span><span class="token punctuation">(</span>savedInstanceState<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">TextView</span> tv <span class="token operator">=</span> <span class="token keyword keyword-new">new</span> <span class="token class-name">TextView</span><span class="token punctuation">(</span><span class="token keyword keyword-this">this</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword keyword-int">int</span> sum <span class="token operator">=</span> <span class="token class-name">Native</span><span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        tv<span class="token punctuation">.</span><span class="token function">setText</span><span class="token punctuation">(</span><span class="token string">&quot;2 + 3 = &quot;</span> <span class="token operator">+</span> <span class="token class-name">Integer</span><span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">(</span>sum<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token function">setContentView</span><span class="token punctuation">(</span>tv<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token keyword keyword-class">class</span> <span class="token class-name">Native</span> <span class="token punctuation">{</span>
    <span class="token keyword keyword-static">static</span> <span class="token punctuation">{</span>
    	<span class="token comment">// The runtime will add &quot;lib&quot; on the front and &quot;.o&quot; on the end of</span>
    	<span class="token comment">// the name supplied to loadLibrary.</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span><span class="token function">loadLibrary</span><span class="token punctuation">(</span><span class="token string">&quot;simplejni&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword keyword-static">static</span> <span class="token keyword keyword-native">native</span> <span class="token keyword keyword-int">int</span> <span class="token function">add</span><span class="token punctuation">(</span><span class="token keyword keyword-int">int</span> a<span class="token punctuation">,</span> <span class="token keyword keyword-int">int</span> b<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

</pre><p>&#x6700;&#x5916;&#x9762;&#x7684; <a href="http://Android.mk">Android.mk</a> &#x7684;&#x5185;&#x5BB9;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="Makefile" class="language-makefile">TOP_LOCAL_PATH<span class="token operator">:=</span> <span class="token variable">$</span><span class="token punctuation">(</span><span class="token keyword keyword-call">call</span> my-dir<span class="token punctuation">)</span>

<span class="token comment"># Build activity</span>

LOCAL_PATH<span class="token operator">:=</span> <span class="token variable">$</span><span class="token punctuation">(</span>TOP_LOCAL_PATH<span class="token punctuation">)</span>
<span class="token keyword keyword-include">include</span> <span class="token variable">$</span><span class="token punctuation">(</span>CLEAR_VARS<span class="token punctuation">)</span>

LOCAL_MODULE_TAGS <span class="token operator">:=</span> optional

LOCAL_SRC_FILES <span class="token operator">:=</span> <span class="token variable">$</span><span class="token punctuation">(</span><span class="token keyword keyword-call">call</span> all-subdir-java-files<span class="token punctuation">)</span>

LOCAL_PACKAGE_NAME <span class="token operator">:=</span> JNIApp

LOCAL_JNI_SHARED_LIBRARIES <span class="token operator">:=</span> myjnilib

LOCAL_PROGUARD_ENABLED <span class="token operator">:=</span> disabled

LOCAL_SDK_VERSION <span class="token operator">:=</span> current

LOCAL_DEX_PREOPT <span class="token operator">:=</span> false

LOCAL_PRODUCT_MODULE <span class="token operator">:=</span> true

<span class="token keyword keyword-include">include</span> <span class="token variable">$</span><span class="token punctuation">(</span>BUILD_PACKAGE<span class="token punctuation">)</span>

<span class="token comment"># ============================================================</span>

<span class="token comment"># Also build all of the sub-targets under this one: the shared library.</span>
<span class="token keyword keyword-include">include</span> <span class="token variable">$</span><span class="token punctuation">(</span><span class="token keyword keyword-call">call</span> all-makefiles-under,<span class="token variable">$</span><span class="token punctuation">(</span>LOCAL_PATH<span class="token punctuation">)</span><span class="token punctuation">)</span>
</pre><p>AndroidManifest.xml &#x7684;&#x5185;&#x5BB9;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="xml" class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>manifest</span> <span class="token attr-name"><span class="token namespace">xmlns:</span>android</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://schemas.android.com/apk/res/android<span class="token punctuation">&quot;</span></span>
      <span class="token attr-name">package</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>com.example.android.simplejni<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>application</span> <span class="token attr-name"><span class="token namespace">android:</span>label</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>Simple JNI<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>activity</span> <span class="token attr-name"><span class="token namespace">android:</span>name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>SimpleJNI<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>intent-filter</span><span class="token punctuation">&gt;</span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>action</span> <span class="token attr-name"><span class="token namespace">android:</span>name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>android.intent.action.MAIN<span class="token punctuation">&quot;</span></span> <span class="token punctuation">/&gt;</span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>category</span> <span class="token attr-name"><span class="token namespace">android:</span>name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>android.intent.category.LAUNCHER<span class="token punctuation">&quot;</span></span> <span class="token punctuation">/&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>intent-filter</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>activity</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>application</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>manifest</span><span class="token punctuation">&gt;</span></span> 
</pre><p>&#x6700;&#x540E;&#x5728; <code>device/Jelly/Rice14/Rice14.mk</code> &#x4E2D;&#x6DFB;&#x52A0;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="Makefile" class="language-makefile">PRODUCT_PACKAGES <span class="token operator">+=</span> helloworld \
    JNIApp \
</pre><p>&#x7F16;&#x8BD1;&#x5E76;&#x8FD0;&#x884C;&#x865A;&#x62DF;&#x673A;&#x5C31;&#x53EF;&#x4EE5;&#x770B;&#x5230; JNIApp &#x4E86;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230306200043.png" alt></p>
<h4 class="mume-header" id="42-jniapp-%E9%93%BE%E6%8E%A5%E8%87%AA%E5%AE%9A%E4%B9%89%E5%BA%93">4.2 JNIApp &#x94FE;&#x63A5;&#x81EA;&#x5B9A;&#x4E49;&#x5E93;</h4>

<p>&#x6211;&#x4EEC;&#x8FD9;&#x91CC;&#x5C1D;&#x8BD5;&#x4FEE;&#x6539; JNIApp&#xFF0C;&#x8BA9;&#x5176;&#x5F15;&#x7528;&#x5230;&#x6211;&#x4EEC;&#x7684; libmymath &#x5E93;&#x3002;</p>
<p>&#x4FEE;&#x6539; JNIApp/jni/Android.mk&#xFF1A;</p>
<pre data-role="codeBlock" data-info="Makefile" class="language-makefile"><span class="token comment"># &#x6DFB;&#x52A0;&#x4EE5;&#x4E0B;&#x5185;&#x5BB9;</span>
LOCAL_SHARED_LIBRARIES <span class="token operator">:=</span> libmymath
</pre><p>&#x4FEE;&#x6539; JNIApp/jni/native.cpp&#xFF1A;</p>
<pre data-role="codeBlock" data-info="c++" class="language-cpp"><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&quot;my_math.h&quot;</span></span>

<span class="token keyword keyword-static">static</span> jint
<span class="token function">add</span><span class="token punctuation">(</span>JNIEnv<span class="token operator">*</span> <span class="token comment">/*env*/</span><span class="token punctuation">,</span> jobject <span class="token comment">/*thiz*/</span><span class="token punctuation">,</span> jint a<span class="token punctuation">,</span> jint b<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword keyword-int">int</span> result <span class="token operator">=</span> a <span class="token operator">+</span> b<span class="token punctuation">;</span>
    result <span class="token operator">=</span> <span class="token function">my_add</span><span class="token punctuation">(</span>result<span class="token punctuation">,</span> result<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">ALOGI</span><span class="token punctuation">(</span><span class="token string">&quot;%d + %d = %d&quot;</span><span class="token punctuation">,</span> a<span class="token punctuation">,</span> b<span class="token punctuation">,</span> result<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword keyword-return">return</span> result<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

</pre><p>&#x7136;&#x540E;&#x7F16;&#x8BD1;&#x7CFB;&#x7EDF;&#xFF0C;&#x53D1;&#x73B0;&#x62A5;&#x4EE5;&#x4E0B;&#x9519;&#x8BEF;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">error: myjnilib <span class="token punctuation">(</span>native:ndk:none:none<span class="token punctuation">)</span> should not <span class="token function">link</span> to libmymath <span class="token punctuation">(</span>native:platform<span class="token punctuation">)</span>
</pre><p>&#x53EF;&#x4EE5;&#x770B;&#x51FA;&#x662F;&#x7F16;&#x8BD1;&#x5E73;&#x53F0;&#x4E0D;&#x4E00;&#x81F4;&#x5BFC;&#x81F4;&#x7684;&#xFF0C;&#x4FEE;&#x6539; JNIApp/jni/Android.mk&#xFF1A;</p>
<pre data-role="codeBlock" data-info="Makefile" class="language-makefile"><span class="token comment"># &#x4E0B;&#x9762;&#x8FD9;&#x884C;&#x6CE8;&#x91CA;&#x6389;&#x5373;&#x53EF;</span>
<span class="token comment"># LOCAL_SDK_VERSION := current</span>
</pre><p>&#x6700;&#x540E;&#x91CD;&#x65B0;&#x7F16;&#x8BD1;&#xFF0C;&#x6267;&#x884C;&#x865A;&#x62DF;&#x673A;&#x5373;&#x53EF;</p>
<h2 class="mume-header" id="%E7%AC%AC%E5%85%AB%E7%AB%A0-%E4%BD%BF%E7%94%A8-android-studio-%E5%BC%80%E5%8F%91%E7%B3%BB%E7%BB%9F-app">&#x7B2C;&#x516B;&#x7AE0; &#x4F7F;&#x7528; Android Studio &#x5F00;&#x53D1;&#x7CFB;&#x7EDF; App</h2>

<h3 class="mume-header" id="1-%E7%BC%96%E8%AF%91-framework-%E6%A8%A1%E5%9D%97">1. &#x7F16;&#x8BD1; framework &#x6A21;&#x5757;</h3>

<p>&#x7CFB;&#x7EDF;&#x5E94;&#x7528;&#x53EF;&#x4EE5;&#x8C03;&#x7528;&#x9690;&#x85CF;&#x7684;API&#xFF0C;&#x8FD9;&#x9700;&#x8981;&#x6211;&#x4EEC;&#x5F15;&#x5165;&#x5305;&#x542B;&#x88AB;&#x9690;&#x85CF; API &#x7684; jar &#x5305;&#x3002;</p>
<p>&#x4E3A;&#x4E86;&#x5F97;&#x5230;&#x8FD9;&#x4E2A; jar &#x5305;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x5728;&#x6E90;&#x7801;&#x4E0B;&#x7F16;&#x8BD1; Framework &#x6A21;&#x5757;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token builtin class-name">source</span> 
lunch rice14-eng
<span class="token comment"># Android10 &#x53CA;&#x4EE5;&#x524D;</span>
<span class="token function">make</span> framework
<span class="token comment"># Android11 &#x53CA;&#x4EE5;&#x540E;</span>
<span class="token comment">#make framework-minus-apex</span>
</pre><p>&#x7F16;&#x8BD1;&#x5B8C;&#x6210;&#x540E;&#xFF0C;&#x6211;&#x4EEC;&#x5728; <code>out/target/common/obj/JAVA_LIBRARIES/framework_intermediates</code> &#x76EE;&#x5F55;&#x4E0B;&#x627E;&#x5230; <code>classes.jar</code> &#x6587;&#x4EF6;&#xFF0C;&#x4E3A;&#x65B9;&#x4FBF;&#x8BC6;&#x522B;&#xFF0C;&#x6211;&#x4EEC;&#x5C06;&#x8BE5;&#x6587;&#x4EF6;&#x62F7;&#x8D1D;&#x5230;&#x5176;&#x4ED6;&#x5730;&#x65B9;&#xFF0C;&#x5E76;&#x5C06;&#x6587;&#x4EF6;&#x540D;&#x4FEE;&#x6539;&#x4E3A; <code>framework.jar</code> &#x3002;</p>
<h3 class="mume-header" id="2-%E5%88%9B%E5%BB%BA%E7%B3%BB%E7%BB%9F-app-%E9%A1%B9%E7%9B%AE">2. &#x521B;&#x5EFA;&#x7CFB;&#x7EDF; App &#x9879;&#x76EE;</h3>

<p>&#x4F7F;&#x7528; Android Studio &#x521B;&#x5EFA;&#x4E00;&#x4E2A; Empty Activity &#x7A7A;&#x9879;&#x76EE;&#x3002;&#x63A5;&#x7740;&#x628A;&#x4E4B;&#x524D;&#x51C6;&#x5907;&#x597D;&#x7684; framework.jar &#x62F7;&#x8D1D;&#x5230;&#x9879;&#x76EE;&#x7684; <code>app/libs</code> &#x6587;&#x4EF6;&#x5939;&#x4E2D;&#x3002;</p>
<p>&#x63A5;&#x7740;&#x4FEE;&#x6539;&#x9879;&#x76EE;&#x6839;&#x76EE;&#x5F55;&#x4E0B;&#x7684; build.gradle&#xFF0C;&#x6DFB;&#x52A0;&#x5982;&#x4E0B;&#x5185;&#x5BB9;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="groovy" class="language-groovy">allprojects<span class="token punctuation">{</span>
    gradle<span class="token punctuation">.</span>projectsEvaluated <span class="token punctuation">{</span>
        tasks<span class="token punctuation">.</span><span class="token function">withType</span><span class="token punctuation">(</span>JavaCompile<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            Set<span class="token operator">&lt;</span>File<span class="token operator">&gt;</span> fileSet <span class="token operator">=</span> options<span class="token punctuation">.</span>bootstrapClasspath<span class="token punctuation">.</span><span class="token function">getFiles</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
            List<span class="token operator">&lt;</span>File<span class="token operator">&gt;</span> newFileList <span class="token operator">=</span> <span class="token keyword keyword-new">new</span> <span class="token class-name">ArrayList</span><span class="token operator">&lt;</span><span class="token operator">&gt;</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            newFileList<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span><span class="token keyword keyword-new">new</span> <span class="token class-name">File</span><span class="token punctuation">(</span><span class="token string">&quot;./app/framework/framework.jar&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
            newFileList<span class="token punctuation">.</span><span class="token function">addAll</span><span class="token punctuation">(</span>fileSet<span class="token punctuation">)</span>
            options<span class="token punctuation">.</span>bootstrapClasspath <span class="token operator">=</span> <span class="token function">files</span><span class="token punctuation">(</span>
                    newFileList<span class="token punctuation">.</span><span class="token function">toArray</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
            <span class="token punctuation">)</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</pre><p>&#x63A5;&#x7740;&#x4FEE;&#x6539; app/build.gradle&#xFF1A;</p>
<pre data-role="codeBlock" data-info="groovy" class="language-groovy">dependencies <span class="token punctuation">{</span>
    compileOnly <span class="token function">files</span><span class="token punctuation">(</span><span class="token string">&apos;libs/framework.jar&apos;</span><span class="token punctuation">)</span>
    <span class="token comment">//.......</span>
<span class="token punctuation">}</span>
</pre><p>&#x7136;&#x540E;&#x5728;&#x9879;&#x76EE;&#x7684; AndroidManifest.xml &#x4E2D;&#x6DFB;&#x52A0;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="xml" class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>manifest</span> <span class="token attr-name"><span class="token namespace">xmlns:</span>android</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://schemas.android.com/apk/res/android<span class="token punctuation">&quot;</span></span>
    <span class="token attr-name"><span class="token namespace">xmlns:</span>tools</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://schemas.android.com/tools<span class="token punctuation">&quot;</span></span>
    <span class="token attr-name"><span class="token namespace">android:</span>sharedUserId</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>android.uid.system<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
</pre><p>&#x63A5;&#x7740;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x5236;&#x4F5C;&#x7CFB;&#x7EDF;&#x7B7E;&#x540D;&#xFF0C;&#x8FD9;&#x91CC;&#x4F7F;&#x7528; <a href="https://github.com/getfatday/keytool-importkeypair">keytool-importkeypair</a> &#x7B7E;&#x540D;&#x5DE5;&#x5177;&#x3002;</p>
<p>&#x5C06; <a href="https://github.com/getfatday/keytool-importkeypair">keytool-importkeypair</a> clone &#x5230;&#x672C;&#x5730;&#xFF0C;&#x5E76;&#x5C06;&#x5176;&#x4E2D;&#x7684; keytool-importkeypair &#x6587;&#x4EF6;&#x6DFB;&#x52A0;&#x5230; PATH &#x8DEF;&#x5F84;&#x3002;</p>
<p>&#x63A5;&#x7740;&#x8FDB;&#x5165;&#x7CFB;&#x7EDF;&#x6E90;&#x7801;&#x4E0B;&#x7684; <code>build/target/product/security</code> &#x8DEF;&#x5F84;&#xFF0C;&#x63A5;&#x7740;&#x6267;&#x884C;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">keytool-importkeypair -k ./platform.keystore -p android -pk8 platform.pk8 -cert platform.x509.pem -alias platform
</pre><p>k &#x8868;&#x793A;&#x8981;&#x751F;&#x6210;&#x7684;&#x7B7E;&#x540D;&#x6587;&#x4EF6;&#x7684;&#x540D;&#x5B57;&#xFF0C;&#x8FD9;&#x91CC;&#x547D;&#x540D;&#x4E3A; platform.keystore<br>
-p &#x8868;&#x793A;&#x8981;&#x751F;&#x6210;&#x7684; keystore &#x7684;&#x5BC6;&#x7801;&#xFF0C;&#x8FD9;&#x91CC;&#x662F; android<br>
-pk8 &#x8868;&#x793A;&#x8981;&#x5BFC;&#x5165;&#x7684; platform.pk8 &#x6587;&#x4EF6;<br>
-cert &#x8868;&#x793A;&#x8981;&#x5BFC;&#x5165;&#x7684;platform.x509.pem<br>
-alias &#x8868;&#x793A;&#x7ED9;&#x751F;&#x6210;&#x7684; platform.keystore &#x53D6;&#x4E00;&#x4E2A;&#x522B;&#x540D;&#xFF0C;&#x8FD9;&#x662F;&#x547D;&#x540D;&#x4E3A; platform</p>
<p>&#x63A5;&#x7740;&#xFF0C;&#x628A;&#x751F;&#x6210;&#x7684;&#x7B7E;&#x540D;&#x6587;&#x4EF6; platform.keystore &#x62F7;&#x8D1D;&#x5230; Android Studio &#x9879;&#x76EE;&#x7684; app &#x76EE;&#x5F55;&#x4E0B;&#xFF0C;&#x7136;&#x540E;&#x5728; app/build.gradle &#x4E2D;&#x6DFB;&#x52A0;&#x7B7E;&#x540D;&#x7684;&#x914D;&#x7F6E;&#x4FE1;&#x606F;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="groovy" class="language-groovy">android <span class="token punctuation">{</span>
    signingConfigs <span class="token punctuation">{</span>
        sign <span class="token punctuation">{</span>
            storeFile <span class="token function">file</span><span class="token punctuation">(</span><span class="token string">&apos;platform.keystore&apos;</span><span class="token punctuation">)</span>
            storePassword <span class="token string">&apos;android&apos;</span>
            keyAlias <span class="token operator">=</span> <span class="token string">&apos;platform&apos;</span>
            keyPassword <span class="token string">&apos;android&apos;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>

    buildTypes <span class="token punctuation">{</span>
        release <span class="token punctuation">{</span>
            minifyEnabled <span class="token boolean">false</span>
            proguardFiles <span class="token function">getDefaultProguardFile</span><span class="token punctuation">(</span><span class="token string">&apos;proguard-android-optimize.txt&apos;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">&apos;proguard-rules.pro&apos;</span>
            signingConfig signingConfigs<span class="token punctuation">.</span>sign
        <span class="token punctuation">}</span>

        debug <span class="token punctuation">{</span>
            minifyEnabled <span class="token boolean">false</span>
            signingConfig signingConfigs<span class="token punctuation">.</span>sign
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</pre><p>&#x81F3;&#x6B64;&#xFF0C;&#x6211;&#x4EEC;&#x5728; AS &#x4E2D;&#x5C31;&#x642D;&#x5EFA;&#x597D;&#x4E86;&#x6211;&#x4EEC;&#x7684;&#x7CFB;&#x7EDF; App</p>
<h3 class="mume-header" id="3-%E7%B3%BB%E7%BB%9F-app-%E7%9A%84%E7%BC%96%E8%AF%91%E8%BF%90%E8%A1%8C">3. &#x7CFB;&#x7EDF; APP &#x7684;&#x7F16;&#x8BD1;&#x8FD0;&#x884C;</h3>

<p>&#x5728;&#x5F00;&#x53D1;&#x8FC7;&#x7A0B;&#x4E2D;&#xFF0C;&#x5927;&#x90E8;&#x5206;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x70B9;&#x51FB; Android Stuido &#x4E2D;&#x7684;&#x8FD0;&#x884C;&#x6309;&#x94AE;&#x6765;&#x8FD0;&#x884C;&#x6211;&#x4EEC;&#x7684;&#x914D;&#x7F6E;&#x597D;&#x7684; App&#x3002;&#x5F53;&#x6211;&#x4EEC;&#x7684; App &#x5F00;&#x53D1;&#x5B8C;&#x6210;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x5C06;&#x5176;&#x9884;&#x5236;&#x5230;&#x7CFB;&#x7EDF;&#x4E2D;&#xFF1A;</p>
<p>&#x6211;&#x4EEC;&#x5728;&#x7CFB;&#x7EDF;&#x6E90;&#x7801;&#x4E0B;&#x7684; <code>device/Jelly/Rice14</code>  &#x76EE;&#x5F55;&#x4E0B;&#xFF0C;&#x521B;&#x5EFA;&#x5982;&#x4E0B;&#x7684;&#x6587;&#x4EF6;&#x4E0E;&#x6587;&#x4EF6;&#x5939;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">AsSystemApp
&#x251C;&#x2500;&#x2500; Android.mk
&#x2514;&#x2500;&#x2500; app.apk
</pre><p>&#x5176;&#x4E2D; app.apk &#x662F;&#x6211;&#x4EEC;&#x7528; Android Studio &#x6253;&#x5305;&#x597D;&#x7684; apk &#x5B89;&#x88C5;&#x5305;&#x3002;<a href="http://Android.mk">Android.mk</a> &#x7684;&#x5185;&#x5BB9;&#x5982;&#x4E0B;(Android10 &#x4E0B;&#xFF0C;Android.bp &#x8C8C;&#x4F3C;&#x8FD8;&#x4E0D;&#x652F;&#x6301;&#x5F15;&#x5165; apk&#xFF0C;&#x5B9E;&#x6D4B; Android13 &#x662F;&#x6CA1;&#x95EE;&#x9898;&#x7684;&#xFF0C;&#x8FD9;&#x91CC;&#x5C31;&#x4F7F;&#x7528; <a href="http://Android.mk">Android.mk</a> &#x4E86;)&#xFF1A;</p>
<pre data-role="codeBlock" data-info="Makefile" class="language-makefile">LOCAL_PATH <span class="token operator">:=</span> <span class="token variable">$</span><span class="token punctuation">(</span><span class="token keyword keyword-call">call</span> my-dir<span class="token punctuation">)</span>
<span class="token keyword keyword-include">include</span> <span class="token variable">$</span><span class="token punctuation">(</span>CLEAR_VARS<span class="token punctuation">)</span>

LOCAL_MODULE_TAGS <span class="token operator">:=</span> optional
LOCAL_MODULE <span class="token operator">:=</span> AsSystemApp
LOCAL_CERTIFICATE <span class="token operator">:=</span> PRESIGNED
LOCAL_SRC_FILES <span class="token operator">:=</span> app.apk
LOCAL_MODULE_CLASS <span class="token operator">:=</span> APPS
LOCAL_PRODUCT_MODULE <span class="token operator">:=</span> true
<span class="token keyword keyword-include">include</span> <span class="token variable">$</span><span class="token punctuation">(</span>BUILD_PREBUILT<span class="token punctuation">)</span>
</pre><p>&#x63A5;&#x7740;&#x4FEE;&#x6539; <code>device/Jelly/Rice14/Rice14.mk</code></p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">PRODUCT_PACKAGES <span class="token operator">+=</span> <span class="token punctuation">\</span>
    AsSystemApp
</pre><p>&#x7136;&#x540E;&#x7F16;&#x8BD1;&#x7CFB;&#x7EDF;&#xFF0C;&#x542F;&#x52A8;&#x865A;&#x62DF;&#x673A;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x6211;&#x4EEC;&#x7684; App &#x4E86;&#x3002;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token builtin class-name">source</span> build/envsetup.sh
lunch Rice14-eng
<span class="token function">make</span> -j16
emulator 
</pre><h3 class="mume-header" id="4-%E7%B3%BB%E7%BB%9F-app-%E7%89%B9%E7%82%B9">4. &#x7CFB;&#x7EDF; App &#x7279;&#x70B9;</h3>

<h4 class="mume-header" id="41-%E7%B3%BB%E7%BB%9F-app-%E5%8F%AF%E4%BB%A5%E6%89%A7%E8%A1%8C%E4%B8%89%E6%96%B9-app-%E4%B8%8D%E8%83%BD%E6%89%A7%E8%A1%8C%E7%9A%84-api">4.1 &#x7CFB;&#x7EDF; app &#x53EF;&#x4EE5;&#x6267;&#x884C;&#x4E09;&#x65B9; App &#x4E0D;&#x80FD;&#x6267;&#x884C;&#x7684; Api</h4>

<p>&#x4E00;&#x4E9B; API &#x53EA;&#x80FD;&#x53C8;&#x7CFB;&#x7EDF; App &#x8C03;&#x7528;&#xFF0C;&#x6BD4;&#x5982;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="kotlin" class="language-kotlin">SystemClock<span class="token punctuation">.</span><span class="token function">setCurrentTimeMillis</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span>
</pre><p>&#x5982;&#x679C;&#x5728;&#x666E;&#x901A; App &#x4E2D;&#x4F7F;&#x7528;&#xFF0C;&#x5C31;&#x4F1A;&#x62A5;&#x4EE5;&#x4E0B;&#x7684;&#x9519;&#x8BEF;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">E/SystemClock: Unable to <span class="token builtin class-name">set</span> RTC
    java.lang.SecurityException: setTime: Neither user <span class="token number">10099</span> nor current process has android.permission.SET_TIME.
</pre><p>&#x7F51;&#x7EDC;&#x4E0A;&#x5F88;&#x591A;&#x6587;&#x7AE0;&#x6559;&#x4F60;&#x5728; App &#x5982;&#x4F55;&#x8C03;&#x7528; Hide &#x7684; Api&#xFF0C;&#x5728;&#x7CFB;&#x7EDF; App &#x4E2D;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#x8FD9;&#x4E9B; Hide Api&#xFF1A;</p>
<pre data-role="codeBlock" data-info="kotlin" class="language-kotlin"><span class="token keyword keyword-import">import</span> android<span class="token punctuation">.</span>os<span class="token punctuation">.</span>SystemClock

<span class="token keyword keyword-class">class</span> MainActivity <span class="token operator">:</span> <span class="token function">AppCompatActivity</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword keyword-override">override</span> <span class="token keyword keyword-fun">fun</span> <span class="token function">onCreate</span><span class="token punctuation">(</span>savedInstanceState<span class="token operator">:</span> Bundle<span class="token operator">?</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword keyword-super">super</span><span class="token punctuation">.</span><span class="token function">onCreate</span><span class="token punctuation">(</span>savedInstanceState<span class="token punctuation">)</span>
        <span class="token function">setContentView</span><span class="token punctuation">(</span>R<span class="token punctuation">.</span>layout<span class="token punctuation">.</span>activity_main<span class="token punctuation">)</span>
        SystemClock<span class="token punctuation">.</span><span class="token function">setCurrentTimeMillis</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span>

        intent <span class="token operator">=</span> <span class="token function">Intent</span><span class="token punctuation">(</span><span class="token keyword keyword-this">this</span><span class="token punctuation">,</span> TestService<span class="token operator">::</span><span class="token keyword keyword-class">class</span><span class="token punctuation">.</span>java<span class="token punctuation">)</span>
        <span class="token function">startService</span><span class="token punctuation">(</span>intent<span class="token punctuation">)</span>

        <span class="token comment">//&#x5728;&#x7CFB;&#x7EDF; App &#x4E2D;&#x53EF;&#x4EE5;&#x6B63;&#x5E38;&#x4F7F;&#x7528;</span>
        <span class="token comment">//AudioSystem &#x6574;&#x4E2A;&#x7C7B;&#x88AB;&#x6807;&#x8BB0;&#x4E3A; hide</span>
        Log<span class="token punctuation">.</span><span class="token function">d</span><span class="token punctuation">(</span><span class="token string">&quot;MainActivity&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;&quot;</span> <span class="token operator">+</span> AudioSystem<span class="token punctuation">.</span>STREAM_ACCESSIBILITY<span class="token punctuation">)</span>

    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</pre><h4 class="mume-header" id="42-%E8%BF%9B%E7%A8%8B%E4%BF%9D%E6%B4%BB">4.2 &#x8FDB;&#x7A0B;&#x4FDD;&#x6D3B;</h4>

<p>&#x4E3A;&#x4E86;&#x4FDD;&#x6D3B;&#xFF0C;&#x5F00;&#x53D1;&#x8005;&#x4E0D;&#x77E5;&#x9053;&#x52A0;&#x4E86;&#x591A;&#x5C11;&#x73ED;&#xFF0C;&#x6389;&#x4E86;&#x591A;&#x5C11;&#x5934;&#x53D1;&#x3002;&#x5728;&#x7CFB;&#x7EDF; App &#x8FD9;&#x91CC;&#xFF0C;&#x53EF;&#x4EE5;&#x8BF4;&#x4FDD;&#x6D3B;&#x4E0D;&#x8981;&#x592A;&#x7B80;&#x5355;&#x4E86;&#xFF1A;</p>
<p>&#x5728; AndroidManifest.xml &#x4E2D;&#x6DFB;&#x52A0;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="xml" class="language-xml"> &lt;application
        android:persistent=&quot;true&quot;
</pre><p>&#x6DFB;&#x52A0;&#x4E00;&#x4E2A; Service&#xFF1A;</p>
<pre data-role="codeBlock" data-info="kotlin" class="language-kotlin"><span class="token keyword keyword-class">class</span> TestService <span class="token operator">:</span> <span class="token function">Service</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>

    <span class="token keyword keyword-override">override</span> <span class="token keyword keyword-fun">fun</span> <span class="token function">onBind</span><span class="token punctuation">(</span>p0<span class="token operator">:</span> Intent<span class="token operator">?</span><span class="token punctuation">)</span><span class="token operator">:</span> IBinder<span class="token operator">?</span> <span class="token punctuation">{</span>
        <span class="token keyword keyword-return">return</span> <span class="token keyword keyword-null">null</span>
    <span class="token punctuation">}</span>

    <span class="token keyword keyword-override">override</span> <span class="token keyword keyword-fun">fun</span> <span class="token function">onCreate</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword keyword-super">super</span><span class="token punctuation">.</span><span class="token function">onCreate</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token function">Thread</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword keyword-while">while</span> <span class="token punctuation">(</span><span class="token boolean">true</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                Log<span class="token punctuation">.</span><span class="token function">d</span><span class="token punctuation">(</span><span class="token string">&quot;TestService&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;this is TestService&quot;</span><span class="token punctuation">)</span>
                Thread<span class="token punctuation">.</span><span class="token function">sleep</span><span class="token punctuation">(</span><span class="token number">2000</span><span class="token punctuation">)</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span><span class="token punctuation">.</span><span class="token function">start</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</pre><p>&#x5728; MainActivity &#x4E2D;&#x542F;&#x52A8; Service&#xFF1A;</p>
<pre data-role="codeBlock" data-info="kotlin" class="language-kotlin">intent <span class="token operator">=</span> <span class="token function">Intent</span><span class="token punctuation">(</span><span class="token keyword keyword-this">this</span><span class="token punctuation">,</span> TestService<span class="token operator">::</span><span class="token keyword keyword-class">class</span><span class="token punctuation">.</span>java<span class="token punctuation">)</span>
<span class="token function">startService</span><span class="token punctuation">(</span>intent<span class="token punctuation">)</span>
</pre><p>&#x6700;&#x540E;&#x4E0D;&#x8981;&#x5FD8;&#x4E86;&#x5728; AndroidManifest.xml &#x4E2D;&#x6DFB;&#x52A0; Service &#x7684;&#x58F0;&#x660E;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="xml" class="language-xml">        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>service</span>
            <span class="token attr-name"><span class="token namespace">android:</span>name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>.TestService<span class="token punctuation">&quot;</span></span>
            <span class="token attr-name"><span class="token namespace">android:</span>enabled</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>true<span class="token punctuation">&quot;</span></span>
            <span class="token attr-name"><span class="token namespace">android:</span>exported</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>true<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>service</span><span class="token punctuation">&gt;</span></span>
</pre><p>&#x6700;&#x540E;&#x76F4;&#x63A5;&#x70B9;&#x51FB;&#x8FD0;&#x884C;&#x6309;&#x94AE;&#x542F;&#x52A8;&#x6211;&#x4EEC;&#x7684; App&#xFF0C;&#x53EF;&#x4EE5;&#x770B;&#x5230; Service &#x4E00;&#x76F4;&#x518D;&#x6253; Log&#x3002;</p>
<p>&#x6211;&#x4EEC;&#x4F7F;&#x7528; <code>ps -ef | grep &quot;AsSystemApp&quot;</code> &#x67E5;&#x627E;&#x5230;&#x6211;&#x4EEC; App &#x5BF9;&#x5E94;&#x7684; pid&#xFF0C;&#x7136;&#x540E;&#x4F7F;&#x7528; kill &#x547D;&#x4EE4;&#x5C06;&#x5176;&#x5F3A;&#x6740;&#x6389;&#xFF0C;&#x7ECF;&#x8FC7;&#x77ED;&#x6682;&#x7684;&#x7B49;&#x5F85;&#x540E;&#xFF0C;Log &#x7A97;&#x53E3;&#x53C8;&#x5F00;&#x59CB;&#x6253; Log &#x4E86;&#xFF0C;&#x8BF4;&#x660E;&#x6211;&#x4EEC;&#x7684; App &#x5728;&#x5F3A;&#x6740;&#x540E;&#xFF0C;&#x88AB;&#x7CFB;&#x7EDF;&#x91CD;&#x65B0;&#x62C9;&#x8D77;&#x8FD0;&#x884C;&#x3002;</p>
<h4 class="mume-header" id="43-%E7%B3%BB%E7%BB%9F-app-%E6%9D%83%E9%99%90">4.3 &#x7CFB;&#x7EDF; App &#x6743;&#x9650;</h4>

<p>&#x76F8;&#x6BD4;&#x4E09;&#x65B9; App&#xFF0C;&#x7CFB;&#x7EDF; App &#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x66F4;&#x591A;&#x7684;&#x6743;&#x9650;&#x3002;&#x56E0;&#x4E3A;&#x8FD9;&#x90E8;&#x5206;&#x5185;&#x5BB9;&#x6D89;&#x53CA;&#x8F83;&#x591A;&#x7CFB;&#x7EDF;&#x6743;&#x9650;&#x76F8;&#x5173;&#x7684;&#x57FA;&#x7840;&#x77E5;&#x8BC6;&#x3002;&#x6211;&#x4EEC;&#x5C31;&#x5728;&#x7CFB;&#x7EDF;&#x6743;&#x9650;&#x90E8;&#x5206;&#x518D;&#x6765;&#x8BB2;&#x89E3;&#x7CFB;&#x7EDF; App &#x6743;&#x9650;&#x76F8;&#x5173;&#x7684;&#x5185;&#x5BB9;&#x5427;&#x3002;</p>
<h2 class="mume-header" id="%E7%AC%AC%E4%B9%9D%E7%AB%A0-seandroid-%E4%BD%BF%E7%94%A8%E6%9E%81%E9%80%9F%E4%B8%8A%E6%89%8B">&#x7B2C;&#x4E5D;&#x7AE0; SeAndroid &#x4F7F;&#x7528;&#x6781;&#x901F;&#x4E0A;&#x624B;</h2>

<h3 class="mume-header" id="1-%E5%9F%BA%E6%9C%AC%E6%A6%82%E5%BF%B5">1. &#x57FA;&#x672C;&#x6982;&#x5FF5;</h3>

<p>SEAndroid &#x662F;&#x4E00;&#x79CD;&#x5B89;&#x5168;&#x7CFB;&#x7EDF;&#xFF0C;&#x76F8;&#x5173;&#x7684;&#x6982;&#x5FF5;&#x548C;&#x672F;&#x8BED;&#x5BF9;&#x4E8E;&#x521D;&#x5B66;&#x8005;&#x6765;&#x8BF4;&#x90FD;&#x76F8;&#x5BF9;&#x6666;&#x6DA9;&#x96BE;&#x61C2;&#x3002;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x7B80;&#x5355;&#x5730;&#x7406;&#x89E3;&#xFF1A;</p>
<ul>
<li>&#x5728; Android &#x7CFB;&#x7EDF;&#x91CC;&#x9762;&#x6709;&#x5F88;&#x591A;&#x8D44;&#x6E90;&#xFF08;&#x8D44;&#x6E90;&#x4E3B;&#x8981;&#x5305;&#x62EC;&#x4E86;&#x6839;&#x6587;&#x4EF6;&#x7CFB;&#x7EDF;&#x4E0B;&#x7684;&#x6587;&#x4EF6;&#xFF0C;&#x5C5E;&#x6027;&#x7CFB;&#x7EDF;&#x4E2D;&#x7684;&#x5C5E;&#x6027;&#xFF0C;binder &#x670D;&#x52A1;&#xFF0C;&#x8FDB;&#x7A0B;&#xFF0C;&#x7528;&#x6237;&#x7B49;&#xFF09;</li>
<li>&#x4E3A;&#x4E86;&#x65B9;&#x4FBF;&#x63CF;&#x8FF0;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x7ED9;&#x8FD9;&#x4E9B;&#x8D44;&#x6E90;&#x53D6;&#x540D;&#x5B57;</li>
<li>&#x4E3A;&#x65B9;&#x4FBF;&#x7BA1;&#x7406;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x7ED9;&#x8D44;&#x6E90;&#x8FDB;&#x884C;&#x5206;&#x7C7B;&#x7BA1;&#x7406;</li>
<li>&#x53E6;&#x5916;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x5B9A;&#x4E49;&#x4E00;&#x4E9B;&#x89C4;&#x5219;&#xFF0C;&#x6765;&#x89C4;&#x8303;&#x8D44;&#x6E90;&#x7684;&#x4F7F;&#x7528;</li>
</ul>
<h4 class="mume-header" id="11-%E8%B5%84%E6%BA%90%E7%9A%84%E5%90%8D%E5%AD%97%E5%AE%89%E5%85%A8%E4%B8%8A%E4%B8%8B%E6%96%87security-context">1.1 &#x8D44;&#x6E90;&#x7684;&#x540D;&#x5B57;&#x2014;&#x2014;&#x5B89;&#x5168;&#x4E0A;&#x4E0B;&#x6587;&#xFF08;security context&#xFF09;</h4>

<p>&#x8D44;&#x6E90;&#x7684;&#x540D;&#x5B57;&#x5728; SEAndroid &#x4E2D;&#x79F0;&#x4E4B;&#x4E3A;&#x5B89;&#x5168;&#x4E0A;&#x4E0B;&#x6587;&#xFF08;security context&#xFF09;&#xFF0C;&#x6211;&#x4EEC;&#x770B;&#x4E00;&#x4E2A;&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token comment"># &#x8FD9;&#x91CC;&#x7684;&#x610F;&#x601D;&#x662F; /dev/myse_dev &#x7684;&#x540D;&#x5B57;&#xFF08;security context&#xFF09;&#x662F; u:object_r:myse_testdev_t:s0</span>
/dev/myse_dev u:object_r:myse_testdev_t:s0
</pre><p><code>u:object_r:myse_testdev_t:s0</code> &#x5C31;&#x662F;&#x4E00;&#x4E2A;&#x5B89;&#x5168;&#x4E0A;&#x4E0B;&#x6587;&#xFF08;security context&#xFF09; &#x7531;4&#x90E8;&#x5206;&#x7EC4;&#x6210;&#xFF1A;</p>
<ul>
<li>u &#x662F; selinux &#x7684;&#x7528;&#x6237;&#x540D;&#xFF08;user&#xFF09;&#xFF0C;&#x5728; Android &#x4E2D;&#x53EA;&#x5B9A;&#x4E49;&#x4E86;&#x4E00;&#x4E2A;&#x7528;&#x6237;&#xFF0C;&#x56FA;&#x5B9A;&#x4E3A; u</li>
<li>object_r &#x662F; selinux &#x4E2D;&#x7684;&#x89D2;&#x8272;&#xFF08;role&#xFF09;&#xFF0C;&#x7C7B;&#x4F3C;&#x4E8E; linux &#x4E2D;&#x7684;&#x7528;&#x6237;&#x7EC4;&#xFF0C;&#x4E00;&#x4E2A;&#x7528;&#x6237;&#x53EF;&#x4EE5;&#x62E5;&#x6709;&#x591A;&#x4E2A;&#x89D2;&#x8272;&#xFF0C;&#x4E0D;&#x540C;&#x7684;</li>
<li>myse_testdev_t &#x662F;&#x8D44;&#x6E90;&#x7684;&#x7C7B;&#x578B;&#xFF0C;&#x5BF9;&#x4E8E;&#x6587;&#x4EF6;&#x6765;&#x8BF4;&#x53EB; type&#xFF0C;&#x5BF9;&#x4E8E;&#x8FDB;&#x7A0B;&#x53EB; domain&#xFF0C;&#x5185;&#x5BB9;&#x4E3A;&#x7528;&#x6237;&#x81EA;&#x5B9A;&#x4E49;</li>
<li>S0 &#x548C; SELinux &#x4E3A;&#x4E86;&#x6EE1;&#x8DB3;&#x519B;&#x7528;&#x548C;&#x6559;&#x80B2;&#x884C;&#x4E1A;&#x800C;&#x8BBE;&#x8BA1;&#x7684; Multi-Level Security&#xFF08;MLS&#xFF09;&#x673A;&#x5236;&#x6709;&#x5173;&#x3002;&#x5728; Android &#x4E2D;&#x56FA;&#x5B9A;&#x4E3A; s0</li>
</ul>
<p>&#x4E0A;&#x9762;&#x8BF4;&#x5230;&#xFF0C;&#x8D44;&#x6E90;&#x7684;&#x7C7B;&#x578B;&#x53EF;&#x4EE5;&#x81EA;&#x5B9A;&#x4E49;&#xFF0C;&#x63A5;&#x4E0B;&#x6765;&#x6211;&#x4EEC;&#x770B;&#x770B;&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#x5177;&#x4F53;&#x5982;&#x4F55;&#x5B9A;&#x4E49;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token comment"># &#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x7C7B;&#x578B; myse_testdev_t&#xFF0C;&#x540E;&#x9762;&#x7684; dev_type &#x8868;&#x793A; myse_testdev_t &#x662F;&#x4E00;&#x4E2A;&#x8BBE;&#x5907;&#x7C7B;&#x578B;</span>
<span class="token builtin class-name">type</span> myse_testdev_t, dev_type<span class="token punctuation">;</span>
</pre><p>&#x8FD9;&#x91CC;&#x7684; dev_type &#x53EF;&#x4EE5;&#x7406;&#x89E3;&#x4E3A;<strong>&#x5B89;&#x5168;&#x4E0A;&#x4E0B;&#x6587;&#x7C7B;&#x578B;&#x7684;&#x7C7B;&#x578B;</strong>&#xFF0C;&#x901A;&#x8FC7; attribute &#x5B9A;&#x4E49;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token comment"># &#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x7C7B;&#x578B; dev_type&#xFF0C;&#x8868;&#x793A;&#x8BBE;&#x5907;&#x7C7B;&#x578B;  &#x6765;&#x81EA; system/sepolicy/public/attributes</span>
attribute dev_type
</pre><p>&#x5F53;&#x5B9A;&#x4E49;&#x597D;&#x5B89;&#x5168;&#x4E0A;&#x4E0B;&#x6587;&#x540E;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x5C06;&#x5B89;&#x5168;&#x4E0A;&#x4E0B;&#x6587;&#xFF08;&#x8D44;&#x6E90;&#x7684;&#x540D;&#x5B57;&#xFF09;&#x4E0E;&#x5177;&#x4F53;&#x7684;&#x8D44;&#x6E90;&#x76F8;&#x5173;&#x8054;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token comment"># &#x8FD9;&#x91CC;&#x7684;&#x610F;&#x601D;&#x662F; /dev/myse_dev &#x7684;&#x540D;&#x5B57;&#xFF08;security context&#xFF09;&#x662F; u:object_r:myse_testdev_t:s0</span>
/dev/myse_dev u:object_r:myse_testdev_t:s0
</pre><h4 class="mume-header" id="12-%E5%AE%9A%E4%B9%89%E8%B5%84%E6%BA%90%E7%9A%84%E4%BD%BF%E7%94%A8%E8%A7%84%E5%88%99">1.2 &#x5B9A;&#x4E49;&#x8D44;&#x6E90;&#x7684;&#x4F7F;&#x7528;&#x89C4;&#x5219;</h4>

<p>&#x4EE5;&#x4E0A;&#x7684;&#x51C6;&#x5907;&#x5DE5;&#x4F5C;&#x5B8C;&#x6210;&#x540E;&#xFF0C;&#x6211;&#x4EEC;&#x5C31;&#x53EF;&#x4EE5;&#x6DFB;&#x52A0;&#x76F8;&#x5E94;&#x7684;&#x89C4;&#x5219;&#x6765;&#x9650;&#x5236;&#x8D44;&#x6E90;&#x7684;&#x8BBF;&#x95EE;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token comment"># &#x793A;&#x4F8B;&#x6765;&#x81EA;&#x4E8E; system/sepolicy/private/adbd.te </span>
<span class="token comment"># &#x5141;&#x8BB8; adbd &#xFF08;&#x5B89;&#x5168;&#x4E0A;&#x4E0B;&#x6587;&#xFF09;&#xFF0C; &#x5BF9;&#x5B89;&#x5168;&#x4E0A;&#x4E0B;&#x6587;&#x4E3A; anr_data_file &#x7684;&#x76EE;&#x5F55;(dir)&#x6709;&#x8BFB;&#x76EE;&#x5F55;&#x6743;&#x9650;</span>
allow adbd anr_data_file:dir r_dir_perms<span class="token punctuation">;</span>
</pre><p>&#x4E0A;&#x9762;&#x8FD9;&#x6761;&#x89C4;&#x5219;&#x7684;&#x610F;&#x601D;&#x662F;&#xFF1A;&#x5141;&#x8BB8; adbd &#xFF08;&#x5B89;&#x5168;&#x4E0A;&#x4E0B;&#x6587;&#xFF09;&#xFF0C; &#x5BF9;&#x5B89;&#x5168;&#x4E0A;&#x4E0B;&#x6587;&#x4E3A; anr_data_file &#x7684;&#x76EE;&#x5F55;(dir)&#x6709;&#x8BFB;&#x76EE;&#x5F55;&#x7684;&#x6743;&#x9650;&#x3002;&#x5176;&#x4E2D; adbd &#x79F0;&#x4E4B;&#x4E3A;&#x4E3B;&#x4F53;&#xFF0C;anr_data_file &#x79F0;&#x4E3A;&#x5BA2;&#x4F53;&#xFF0C;dir &#x8868;&#x793A;&#x5BA2;&#x4F53;&#x7684;&#x7C7B;&#x578B;&#x662F;&#x76EE;&#x5F55;&#xFF0C;&#x7C7B;&#x578B;&#x7684;&#x5B9A;&#x4E49;&#x4F4D;&#x4E8E;&#xFF1A;<code>system/sepolicy/private/security_classes</code> :</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">class security
class process
class system
class capability

<span class="token comment"># file-related classes</span>
class filesystem
class <span class="token function">file</span>
class <span class="token function">dir</span>
class fd
class lnk_file
class chr_file
class blk_file
class sock_file
class fifo_file

<span class="token comment"># network-related classes</span>
class socket
class tcp_socket
class udp_socket
class rawip_socket
class node
class netif
class netlink_socket
class packet_socket
class key_socket
class unix_stream_socket
class unix_dgram_socket

<span class="token comment"># &#x7701;&#x7565;</span>
<span class="token comment">#.......</span>
</pre><p>r_dir_perms &#x8868;&#x793A;&#x76EE;&#x5F55;&#x7684;&#x8BFB;&#x6743;&#x9650;&#xFF0C;&#x5B9A;&#x4E49;&#x5728; <code>system/sepolicy/public/global_macros</code>&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token comment"># ......</span>
define<span class="token punctuation">(</span><span class="token variable"><span class="token variable">`</span>x_file_perms&apos;, <span class="token variable">`</span></span><span class="token punctuation">{</span> getattr execute execute_no_trans map <span class="token punctuation">}</span><span class="token string">&apos;)
define(`r_file_perms&apos;</span>, <span class="token variable"><span class="token variable">`</span><span class="token punctuation">{</span> getattr <span class="token function">open</span> <span class="token builtin class-name">read</span> ioctl lock map <span class="token punctuation">}</span>&apos;<span class="token punctuation">)</span>
define<span class="token punctuation">(</span><span class="token variable">`</span></span>w_file_perms<span class="token string">&apos;, `{ open append write lock map }&apos;</span><span class="token punctuation">)</span>
define<span class="token punctuation">(</span><span class="token variable"><span class="token variable">`</span>rx_file_perms&apos;, <span class="token variable">`</span></span><span class="token punctuation">{</span> r_file_perms x_file_perms <span class="token punctuation">}</span><span class="token string">&apos;)
define(`ra_file_perms&apos;</span>, <span class="token variable"><span class="token variable">`</span><span class="token punctuation">{</span> r_file_perms append <span class="token punctuation">}</span>&apos;<span class="token punctuation">)</span>
define<span class="token punctuation">(</span><span class="token variable">`</span></span>rw_file_perms<span class="token string">&apos;, `{ r_file_perms w_file_perms }&apos;</span><span class="token punctuation">)</span>
define<span class="token punctuation">(</span><span class="token variable"><span class="token variable">`</span>rwx_file_perms&apos;, <span class="token variable">`</span></span><span class="token punctuation">{</span> rw_file_perms x_file_perms <span class="token punctuation">}</span><span class="token string">&apos;)
define(`create_file_perms&apos;</span>, `<span class="token punctuation">{</span> create <span class="token function">rename</span> setattr unlink rw_file_perms <span class="token punctuation">}</span>&apos;<span class="token punctuation">)</span>
<span class="token comment">#......</span>
</pre><h4 class="mume-header" id="13-%E7%B1%BB%E5%9E%8B%E8%BD%AC%E6%8D%A2domaintype-transition">1.3 &#x7C7B;&#x578B;&#x8F6C;&#x6362;&#xFF08;Domain/Type Transition&#xFF09;</h4>

<p>&#x7CFB;&#x7EDF;&#x5728;&#x8FD0;&#x884C;&#x7684;&#x8FC7;&#x7A0B;&#x4E2D;&#xFF0C;&#x8D44;&#x6E90;&#x7684;&#x540D;&#x5B57;&#xFF08;&#x5B89;&#x5168;&#x4E0A;&#x4E0B;&#x6587;&#xFF09;&#x662F;&#x4F1A;&#x53D8;&#x5316;&#x7684;&#xFF0C;&#x4E00;&#x4E2A;&#x5E38;&#x89C1;&#x7684;&#x4F8B;&#x5B50;&#xFF1A;init &#x8FDB;&#x7A0B;&#x7684;&#x540D;&#x5B57;&#x4E3A; u:r:init:s0&#xFF0C;&#x800C; init fork &#x7684;&#x5B50;&#x8FDB;&#x7A0B;&#x663E;&#x7136;&#x4E0D;&#x4F1A;&#x4E5F;&#x4E0D;&#x5E94;&#x8BE5;&#x62E5;&#x6709;&#x548C; init &#x8FDB;&#x7A0B;&#x4E00;&#x6837;&#x7684;&#x540D;&#x5B57;&#xFF0C;&#x5426;&#x5219;&#x8FD9;&#x4E9B;&#x5B50;&#x8FDB;&#x7A0B;&#x5C31;&#x6709;&#x4E86;&#x548C; init &#x4E00;&#x6837;&#x7684;&#x6743;&#x9650;&#xFF0C;&#x8FD9;&#x4E0D;&#x662F;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x7684;&#x7ED3;&#x679C;&#x3002;&#x8FD9;&#x6837;&#x7684;&#x95EE;&#x9898;&#x79F0;&#x4E4B;&#x4E3A;<strong>&#x7C7B;&#x578B;&#x8F6C;&#x6362;&#xFF08;Domain/Type Transition&#xFF09;</strong> &#x3002;</p>
<p>&#x63A5;&#x7740;&#x6211;&#x4EEC;&#x6765;&#x770B;&#x4E00;&#x4E2A;&#x7C7B;&#x578B;&#x8F6C;&#x6362;&#x7684;&#x4F8B;&#x5B50;(&#x4F8B;&#x5B50;&#x6765;&#x81EA;&#x8FD9;&#x91CC;<a href="https://blog.csdn.net/innost/article/details/19299937">&#x6DF1;&#x5165;&#x7406;&#x89E3;SELinux SEAndroid&#xFF08;&#x7B2C;&#x4E00;&#x90E8;&#x5206;&#xFF09;</a>)&#xFF1A;</p>
<pre data-role="codeBlock" data-info class="language-"><code>type_transition init_t apache_exec_t : process apache_t;
</code></pre><p>type_transition &#x7528;&#x4E8E;&#x5B9A;&#x4E49;&#x7C7B;&#x578B;&#x8F6C;&#x6362;&#xFF0C;&#x4E0A;&#x8FF0;&#x8BED;&#x53E5;&#x7684;&#x610F;&#x601D;&#x662F;&#xFF1A;init_t &#x5728;&#x6267;&#x884C;&#xFF08;fork &#x5E76; execv&#xFF09;&#x7C7B;&#x578B;&#x4E3A; apache_exec_t &#x7684;&#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;&#x65F6;&#xFF0C;&#x5BF9;&#x5E94;&#x7684;&#x8FDB;&#x7A0B;&#xFF08;process&#xFF09;&#x7684;&#x7C7B;&#x578B;&#x8981;&#x5207;&#x6362;&#x5230; apache_t</p>
<p>&#x4E0A;&#x9762;&#x7684;&#x5207;&#x6362;&#x5E76;&#x4E0D;&#x5B8C;&#x6574;&#xFF0C;&#x9700;&#x8981;&#x5B8C;&#x6210;&#x5207;&#x6362;&#xFF0C;&#x8FD8;&#x9700;&#x8981;&#x4E0B;&#x9762;&#x7684;&#x89C4;&#x5219;&#x914D;&#x5408;&#xFF1A;</p>
<pre data-role="codeBlock" data-info class="language-"><code># init_t &#x8FDB;&#x7A0B;&#x80FD;&#x591F;&#x6267;&#x884C; type &#x4E3A; apache_exec_t &#x7684;&#x6587;&#x4EF6;
allow init_t apache_exec_t : file execute;
# &#x5141;&#x8BB8; init_t &#x5207;&#x6362;&#x8FDB;&#x5165; apache_t
allow init_t apache_t : process transition;
# &#x5207;&#x6362;&#x5165;&#x53E3;&#xFF08;&#x5BF9;&#x5E94;&#x4E3A;entrypoint&#x6743;&#x9650;&#xFF09;&#x4E3A; apache_exec_t
allow apache_t apache_exec_t : file entrypoint;
</code></pre><p>&#x6BCF;&#x6B21;&#x90FD;&#x8FD9;&#x6837;&#x5199;&#x7A0D;&#x663E;&#x9EBB;&#x70E6;&#xFF0C;SeAndroid &#x5B9A;&#x4E49;&#x4E86;&#x4E00;&#x4E2A;&#x5B8F; domain_auto_trans &#x6765;&#x5E2E;&#x6211;&#x4EEC;&#x5B8C;&#x6210;&#x4E0A;&#x8FF0;&#x6240;&#x6709;&#x529F;&#x80FD;&#xFF1A;</p>
<pre data-role="codeBlock" data-info class="language-"><code>domain_auto_trans(init_t, apache_exec_t, apache_t)
</code></pre><p>&#x9488;&#x5BF9;&#x6587;&#x4EF6;&#xFF0C;&#x4E5F;&#x9700;&#x8981;&#x505A;&#x7C7B;&#x578B;&#x8F6C;&#x6362;&#xFF0C;&#x6BD4;&#x5982;&#xFF1A;</p>
<pre data-role="codeBlock" data-info class="language-"><code>file_type_auto_trans(appdomain, download_file, download_file)
</code></pre><p>&#x4E0A;&#x8FF0;&#x89C4;&#x5219;&#x7684;&#x610F;&#x601D;&#x662F;&#xFF0C;&#x5F53;&#x8D44;&#x6E90;&#x540D;&#xFF08;&#x5B89;&#x5168;&#x4E0A;&#x4E0B;&#x6587;&#xFF09;&#x4E3A; appdomain &#x7684;&#x8FDB;&#x7A0B;&#x5728;&#x8D44;&#x6E90;&#x540D;&#xFF08;&#x5B89;&#x5168;&#x4E0A;&#x4E0B;&#x6587;&#xFF09;&#x4E3A; download_file &#x7684;&#x6587;&#x4EF6;&#x5939;&#x4E2D;&#x521B;&#x5EFA;&#x65B0;&#x7684;&#x6587;&#x4EF6;&#x65F6;&#xFF0C;&#x65B0;&#x6587;&#x4EF6;&#x7684;&#x8D44;&#x6E90;&#x540D;&#xFF08;&#x5B89;&#x5168;&#x4E0A;&#x4E0B;&#x6587;&#xFF09;&#x4E3A; download_file</p>
<h3 class="mume-header" id="2-hello-seandroid-%E7%A4%BA%E4%BE%8B">2. Hello SeAndroid &#x793A;&#x4F8B;</h3>

<p>SEAndroid &#x76F8;&#x5173;&#x7684;&#x5185;&#x5BB9;&#x7E41;&#x591A;&#xFF0C;&#x8981;&#x5B8C;&#x5168;&#x638C;&#x63E1;&#x5176;&#x7EC6;&#x8282;&#x8D39;&#x795E;&#x8D39;&#x529B;&#xFF0C;&#x4E00;&#x822C;&#x901A;&#x8FC7;&#x793A;&#x4F8B;&#x6765;&#x5B66;&#x4E60;&#x548C;&#x79EF;&#x7D2F;&#x3002;&#x8FD9;&#x91CC;&#x6F14;&#x793A;&#x4E00;&#x4E2A;&#x8BBF;&#x95EE;&#x8BBE;&#x5907;&#x6587;&#x4EF6;&#x7684; CPP &#x53EF;&#x6267;&#x884C;&#x7A0B;&#x5E8F;&#x3002;</p>
<p>&#x5728; <code>device/Jelly/Rice14</code> &#x76EE;&#x5F55;&#x4E0B;&#x6DFB;&#x52A0;&#x5982;&#x4E0B;&#x7684;&#x6587;&#x4EF6;&#x548C;&#x6587;&#x4EF6;&#x5939;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">hello_seandroid
&#x251C;&#x2500;&#x2500; Android.bp
&#x2514;&#x2500;&#x2500; hello_seandroid.c

sepolicy
&#x251C;&#x2500;&#x2500; device.te
&#x251C;&#x2500;&#x2500; file_contexts
&#x2514;&#x2500;&#x2500; hello_se.te
</pre><p>hello_seandroid &#x76EE;&#x5F55;&#x4E0B;&#x662F;&#x4E00;&#x4E2A;&#x8BFB;&#x53D6;&#x6587;&#x4EF6;&#x7684;&#x53EF;&#x6267;&#x884C;&#x7A0B;&#x5E8F;&#xFF1A;</p>
<p>hello_seandroid.c:</p>
<pre data-role="codeBlock" data-info="c" class="language-c"><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;unistd.h&gt;</span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;string.h&gt;</span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;sys/types.h&gt;</span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;sys/stat.h&gt;</span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;fcntl.h&gt;</span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;errno.h&gt;</span></span>

<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">define</span> <span class="token macro-name">LOG_TAG</span> <span class="token string">&quot;helloseandroid&quot;</span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;log/log.h&gt;</span></span>

<span class="token keyword keyword-int">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token keyword keyword-int">int</span> argc<span class="token punctuation">,</span> <span class="token keyword keyword-char">char</span> <span class="token operator">*</span>argv<span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span>
<span class="token punctuation">{</span>
	
	<span class="token keyword keyword-int">int</span> fd  <span class="token operator">=</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">;</span>
	<span class="token keyword keyword-int">int</span> ret <span class="token operator">=</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">;</span>
	<span class="token keyword keyword-char">char</span> <span class="token operator">*</span>content <span class="token operator">=</span> <span class="token string">&quot;hello test for selinux&quot;</span><span class="token punctuation">;</span>
	<span class="token keyword keyword-char">char</span> <span class="token operator">*</span>dev_name <span class="token operator">=</span> <span class="token string">&quot;/dev/hello_seandroid_dev&quot;</span><span class="token punctuation">;</span>
	fd <span class="token operator">=</span> <span class="token function">open</span><span class="token punctuation">(</span>dev_name<span class="token punctuation">,</span> O_RDWR<span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token keyword keyword-if">if</span><span class="token punctuation">(</span>fd <span class="token operator">&lt;</span> <span class="token number">0</span><span class="token punctuation">)</span>
	<span class="token punctuation">{</span>
		<span class="token function">ALOGE</span><span class="token punctuation">(</span><span class="token string">&quot;open %s error: %s&quot;</span><span class="token punctuation">,</span> dev_name<span class="token punctuation">,</span> <span class="token function">strerror</span><span class="token punctuation">(</span>errno<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token keyword keyword-return">return</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>

	ret <span class="token operator">=</span> <span class="token function">write</span><span class="token punctuation">(</span>fd<span class="token punctuation">,</span> content<span class="token punctuation">,</span> <span class="token function">strlen</span><span class="token punctuation">(</span>content<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>	
	<span class="token keyword keyword-if">if</span><span class="token punctuation">(</span>ret <span class="token operator">&lt;</span> <span class="token number">0</span><span class="token punctuation">)</span>
	<span class="token punctuation">{</span>
		<span class="token function">ALOGE</span><span class="token punctuation">(</span><span class="token string">&quot;write testfile error: %s&quot;</span><span class="token punctuation">,</span> <span class="token function">strerror</span><span class="token punctuation">(</span>errno<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token keyword keyword-return">return</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span><span class="token keyword keyword-else">else</span>
	<span class="token punctuation">{</span>
		<span class="token function">ALOGD</span><span class="token punctuation">(</span><span class="token string">&quot;write testfile ok: %d&quot;</span><span class="token punctuation">,</span>  ret<span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	
	<span class="token keyword keyword-while">while</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

	<span class="token function">close</span><span class="token punctuation">(</span>fd<span class="token punctuation">)</span><span class="token punctuation">;</span>

	<span class="token keyword keyword-return">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</pre><p>&#x8FD9;&#x6BB5;&#x7A0B;&#x5E8F;&#x7684;&#x4E3B;&#x8981;&#x4F5C;&#x7528;&#x5C31;&#x662F;&#x5411; <code>/dev/hello_seandroid_dev</code> &#x6587;&#x4EF6;&#x5199;&#x5165;&#x4E00;&#x6BB5;&#x5B57;&#x7B26;&#x4E32;&#x3002;</p>
<p>Android.bp&#xFF1A;</p>
<pre data-role="codeBlock" data-info="json" class="language-json">cc_binary <span class="token punctuation">{</span>                 
    name<span class="token operator">:</span> <span class="token string">&quot;helloseandroid&quot;</span><span class="token punctuation">,</span>         
    srcs<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;hello_seandroid.c&quot;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>    
    cflags<span class="token operator">:</span> <span class="token punctuation">[</span>
        <span class="token string">&quot;-Werror&quot;</span><span class="token punctuation">,</span>
        <span class="token string">&quot;-Wno-unused-parameter&quot;</span>
    <span class="token punctuation">]</span><span class="token punctuation">,</span>    
	<span class="token comment">//Android10 &#x4E0A;&#x8C8C;&#x4F3C;&#x4E0D;&#x652F;&#x6301;&#x914D;&#x7F6E; product &#x5206;&#x533A;&#x7684; sepolicy&#xFF08;Android 11 &#x53CA;&#x4EE5;&#x540E;&#x662F;&#x652F;&#x6301;&#x7684;&#xFF09;</span>
	<span class="token comment">//&#x6240;&#x4EE5;&#x53EA;&#x80FD;&#x9009;&#x62E9; vendor &#x5206;&#x533A;&#x4E86;</span>
    vendor<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
    shared_libs<span class="token operator">:</span> <span class="token punctuation">[</span>
        <span class="token string">&quot;libcutils&quot;</span><span class="token punctuation">,</span>
        <span class="token string">&quot;liblog&quot;</span>
    <span class="token punctuation">]</span>
<span class="token punctuation">}</span>
</pre><p>hello_se.te&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token comment"># &#x8FDB;&#x7A0B;&#x5BF9;&#x5E94;&#x7684;&#x7C7B;&#x578B;</span>
<span class="token builtin class-name">type</span>  hello_se_dt, domain<span class="token punctuation">;</span>
<span class="token comment"># &#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;&#x5BF9;&#x5E94;&#x7684;&#x7C7B;&#x578B;</span>
<span class="token builtin class-name">type</span>  hello_se_dt_exec, exec_type, vendor_file_type, file_type<span class="token punctuation">;</span>
<span class="token comment">#&#x8868;&#x793A;&#x8BE5;&#x7A0B;&#x5E8F;&#x5982;&#x679C;&#x4ECE; init &#x8FDB;&#x7A0B;&#x542F;&#x52A8; hello_seandroid_dt_exec&#xFF0C;&#x5176;&#x5B89;&#x5168;&#x4E0A;&#x4E0B;&#x6587;&#x7684; domain &#x90E8;&#x5206;&#x4ECE; init &#x8F6C;&#x5316;&#x4E3A; hello_seandroid_dt</span>
init_daemon_domain<span class="token punctuation">(</span>hello_se_dt<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">#&#x4ECE; shell &#x542F;&#x52A8; type &#x4E3A; hello_seandroid_dt_exec &#x7684;&#x53EF;&#x6267;&#x884C;&#x7A0B;&#x5E8F;&#xFF0C;&#x5176;&#x5BF9;&#x5E94;&#x8FDB;&#x7A0B;&#x7684; domain &#x4E3A; hello_seandroid_dt</span>
domain_auto_trans<span class="token punctuation">(</span>shell, hello_se_dt_exec, hello_se_dt<span class="token punctuation">)</span><span class="token punctuation">;</span>
</pre><p>device.te&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token comment"># &#x5B9A;&#x4E49;&#x8BBE;&#x5907; /dev/hello_seandroid_dev &#x7684;&#x7C7B;&#x578B;</span>
<span class="token builtin class-name">type</span> hello_se_dev_t, dev_type<span class="token punctuation">;</span>
</pre><p>file_contexts&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">/vendor/bin/helloseandroid     u:object_r:hello_se_dt_exec:s0
/dev/hello_seandroid_dev        u:object_r:hello_se_dev_t:s0
</pre><p>&#x7F16;&#x8BD1;&#x8FD0;&#x884C;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token builtin class-name">source</span> build/envsetup.sh
<span class="token comment"># &#x6CE8;&#x610F;&#x8FD9;&#x91CC;&#x7684;&#x7248;&#x672C;&#x548C;&#x524D;&#x9762;&#x4E0D;&#x4E00;&#x6837;&#x4E86;&#xFF0C;&#x9009;&#x62E9;&#x4E86; userdebug</span>
lunch Rice14-userdebug
<span class="token function">make</span> -j16
</pre><p>&#x51C6;&#x5907;&#x5DE5;&#x4F5C;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token comment">#&#x8FDB;&#x5165;Android shell &#x73AF;&#x5883;</span>
adb shell
 
<span class="token comment"># &#x521B;&#x5EFA;&#x5F85;&#x8BBF;&#x95EE;&#x7684;&#x8BBE;&#x5907;&#x6587;&#x4EF6;</span>
<span class="token function">su</span> <span class="token comment">#&#x4F7F;&#x7528; root </span>
<span class="token function">touch</span> /dev/hello_seandroid_dev
<span class="token function">ls</span> -Z /dev/hello_seandroid_dev                     
u:object_r:device:s0 /dev/hello_seandroid_dev
<span class="token comment"># &#x52A0;&#x8F7D; file_contexts</span>
restorecon /dev/hello_seandroid_dev
<span class="token comment"># &#x67E5;&#x770B;&#x6587;&#x4EF6;&#x7684;&#x5B89;&#x5168;&#x4E0A;&#x4E0B;&#x6587;</span>
<span class="token function">ls</span> -Z /dev/hello_seandroid_dev           
u:object_r:hello_se_dev_t:s0 /dev/hello_seandroid_dev
<span class="token comment">#&#x653E;&#x5BBD;&#x6743;&#x9650;</span>
<span class="token function">chmod</span> <span class="token number">777</span> /dev/hello_seandroid_dev 
<span class="token comment"># &#x67E5;&#x770B;&#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;&#x7684;&#x5B89;&#x5168;&#x4E0A;&#x4E0B;&#x6587;</span>
<span class="token function">ls</span> -Z /vendor/bin/helloseandroid
u:object_r:hello_se_dt_exec:s0 /vendor/bin/helloseandroid
</pre><p>&#x6211;&#x4EEC;&#x6CA1;&#x6709;&#x914D;&#x7F6E; selinux &#x6743;&#x9650;&#xFF0C;&#x6240;&#x4EE5;&#x6211;&#x4EEC;&#x7684;&#x7A0B;&#x5E8F;&#x662F;&#x4E0D;&#x80FD;&#x6210;&#x529F;&#x6267;&#x884C;&#x7684;&#xFF0C;&#x4F46;&#x662F;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x901A;&#x8FC7; <code>setenforce 0</code> &#x547D;&#x4EE4;&#x5207;&#x6362;&#x5230; selinux permissive &#x6A21;&#x5F0F;&#xFF0C;&#x8BE5;&#x6A21;&#x5F0F;&#x4E0B;&#x4E0D;&#x4F1A;&#x963B;&#x6B62;&#x8FDB;&#x7A0B;&#x7684;&#x884C;&#x4E3A;&#xFF0C;&#x53EA;&#x4F1A;&#x6253;&#x5370;&#x6743;&#x9650;&#x7F3A;&#x5931;&#x4FE1;&#x606F;&#xFF0C;&#x8FD9;&#x6837;&#x6211;&#x4EEC;&#x5C31;&#x53EF;&#x4EE5;&#x6267;&#x884C;&#x6211;&#x4EEC;&#x7684;&#x7A0B;&#x5E8F;&#xFF0C;&#x5E76;&#x5F97;&#x5230;&#x7F3A;&#x5931;&#x7684;&#x6743;&#x9650;&#x4FE1;&#x606F;&#xFF0C;&#x7136;&#x540E;&#x901A;&#x8FC7;&#x6E90;&#x7801;&#x63D0;&#x4F9B;&#x7684; audit2allow &#x5DE5;&#x5177;&#x5E2E;&#x6211;&#x4EEC;&#x751F;&#x6210;&#x5BF9;&#x4E8E;&#x7684; selinux &#x6743;&#x9650;&#x4FE1;&#x606F;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">setenforce <span class="token number">0</span>
<span class="token builtin class-name">exit</span> <span class="token comment">#&#x9000;&#x51FA; root</span>
<span class="token comment"># &#x6267;&#x884C;&#x7A0B;&#x5E8F;</span>
helloseandroid <span class="token operator">&amp;</span>
</pre><p>&#x63A5;&#x7740;&#x67E5;&#x770B; log&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">logcat <span class="token operator">|</span> <span class="token function">grep</span> <span class="token string">&quot;helloseandroid&quot;</span> --line-buffered <span class="token operator">|</span> <span class="token function">grep</span> <span class="token string">&quot;avc&quot;</span>               

04-08 <span class="token number">15</span>:11:05.290  <span class="token number">6595</span>  <span class="token number">6595</span> I helloseandroid: <span class="token assign-left variable">type</span><span class="token operator">=</span><span class="token number">1400</span> audit<span class="token punctuation">(</span><span class="token number">0.0</span>:36<span class="token punctuation">)</span>: avc: denied <span class="token punctuation">{</span> use <span class="token punctuation">}</span> <span class="token keyword keyword-for">for</span> <span class="token assign-left variable">path</span><span class="token operator">=</span><span class="token string">&quot;/dev/pts/0&quot;</span> <span class="token assign-left variable">dev</span><span class="token operator">=</span><span class="token string">&quot;devpts&quot;</span> <span class="token assign-left variable">ino</span><span class="token operator">=</span><span class="token number">3</span> <span class="token assign-left variable">scontext</span><span class="token operator">=</span>u:r:hello_se_dt:s0 <span class="token assign-left variable">tcontext</span><span class="token operator">=</span>u:r:adbd:s0 <span class="token assign-left variable">tclass</span><span class="token operator">=</span>fd <span class="token assign-left variable">permissive</span><span class="token operator">=</span><span class="token number">1</span>
04-08 <span class="token number">15</span>:11:05.290  <span class="token number">6595</span>  <span class="token number">6595</span> I helloseandroid: <span class="token assign-left variable">type</span><span class="token operator">=</span><span class="token number">1400</span> audit<span class="token punctuation">(</span><span class="token number">0.0</span>:37<span class="token punctuation">)</span>: avc: denied <span class="token punctuation">{</span> <span class="token builtin class-name">read</span> <span class="token function">write</span> <span class="token punctuation">}</span> <span class="token keyword keyword-for">for</span> <span class="token assign-left variable">path</span><span class="token operator">=</span><span class="token string">&quot;/dev/pts/0&quot;</span> <span class="token assign-left variable">dev</span><span class="token operator">=</span><span class="token string">&quot;devpts&quot;</span> <span class="token assign-left variable">ino</span><span class="token operator">=</span><span class="token number">3</span> <span class="token assign-left variable">scontext</span><span class="token operator">=</span>u:r:hello_se_dt:s0 <span class="token assign-left variable">tcontext</span><span class="token operator">=</span>u:object_r:devpts:s0 <span class="token assign-left variable">tclass</span><span class="token operator">=</span>chr_file <span class="token assign-left variable">permissive</span><span class="token operator">=</span><span class="token number">1</span>
04-08 <span class="token number">15</span>:11:05.290  <span class="token number">6595</span>  <span class="token number">6595</span> I helloseandroid: <span class="token assign-left variable">type</span><span class="token operator">=</span><span class="token number">1400</span> audit<span class="token punctuation">(</span><span class="token number">0.0</span>:38<span class="token punctuation">)</span>: avc: denied <span class="token punctuation">{</span> <span class="token builtin class-name">read</span> <span class="token function">write</span> <span class="token punctuation">}</span> <span class="token keyword keyword-for">for</span> <span class="token assign-left variable">path</span><span class="token operator">=</span><span class="token string">&quot;socket:[10425]&quot;</span> <span class="token assign-left variable">dev</span><span class="token operator">=</span><span class="token string">&quot;sockfs&quot;</span> <span class="token assign-left variable">ino</span><span class="token operator">=</span><span class="token number">10425</span> <span class="token assign-left variable">scontext</span><span class="token operator">=</span>u:r:hello_se_dt:s0 <span class="token assign-left variable">tcontext</span><span class="token operator">=</span>u:r:adbd:s0 <span class="token assign-left variable">tclass</span><span class="token operator">=</span>unix_stream_socket <span class="token assign-left variable">permissive</span><span class="token operator">=</span><span class="token number">1</span>
04-08 <span class="token number">15</span>:11:05.290  <span class="token number">6595</span>  <span class="token number">6595</span> I helloseandroid: <span class="token assign-left variable">type</span><span class="token operator">=</span><span class="token number">1400</span> audit<span class="token punctuation">(</span><span class="token number">0.0</span>:39<span class="token punctuation">)</span>: avc: denied <span class="token punctuation">{</span> use <span class="token punctuation">}</span> <span class="token keyword keyword-for">for</span> <span class="token assign-left variable">path</span><span class="token operator">=</span><span class="token string">&quot;/vendor/bin/helloseandroid&quot;</span> <span class="token assign-left variable">dev</span><span class="token operator">=</span><span class="token string">&quot;dm-1&quot;</span> <span class="token assign-left variable">ino</span><span class="token operator">=</span><span class="token number">71</span> <span class="token assign-left variable">scontext</span><span class="token operator">=</span>u:r:hello_se_dt:s0 <span class="token assign-left variable">tcontext</span><span class="token operator">=</span>u:r:shell:s0 <span class="token assign-left variable">tclass</span><span class="token operator">=</span>fd <span class="token assign-left variable">permissive</span><span class="token operator">=</span><span class="token number">1</span>
04-08 <span class="token number">15</span>:11:05.300  <span class="token number">6595</span>  <span class="token number">6595</span> I helloseandroid: <span class="token assign-left variable">type</span><span class="token operator">=</span><span class="token number">1400</span> audit<span class="token punctuation">(</span><span class="token number">0.0</span>:40<span class="token punctuation">)</span>: avc: denied <span class="token punctuation">{</span> <span class="token builtin class-name">read</span> <span class="token function">write</span> <span class="token punctuation">}</span> <span class="token keyword keyword-for">for</span> <span class="token assign-left variable">name</span><span class="token operator">=</span><span class="token string">&quot;hello_seandroid_dev&quot;</span> <span class="token assign-left variable">dev</span><span class="token operator">=</span><span class="token string">&quot;tmpfs&quot;</span> <span class="token assign-left variable">ino</span><span class="token operator">=</span><span class="token number">23235</span> <span class="token assign-left variable">scontext</span><span class="token operator">=</span>u:r:hello_se_dt:s0 <span class="token assign-left variable">tcontext</span><span class="token operator">=</span>u:object_r:hello_se_dev_t:s0 <span class="token assign-left variable">tclass</span><span class="token operator">=</span>file <span class="token assign-left variable">permissive</span><span class="token operator">=</span><span class="token number">1</span>
</pre><p>&#x6211;&#x4EEC;&#x628A;&#x6743;&#x9650;&#x76F8;&#x5173;&#x7684; log &#x590D;&#x5236;&#x4E0B;&#x6765;&#xFF0C;&#x5728;&#x6E90;&#x7801;&#x76EE;&#x5F55;&#x4E0B;&#xFF0C;&#x4FDD;&#x5B58;&#x5230; avc_log.txt &#x6587;&#x4EF6;&#x4E2D;&#xFF0C;&#x5E76;&#x6267;&#x884C;&#x4E00;&#x4E0B;&#x547D;&#x4EE4;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token builtin class-name">source</span> build/envsetup.sh
audit2allow -i avc_log.txt

allow hello_se_dt adbd:unix_stream_socket <span class="token punctuation">{</span> <span class="token builtin class-name">read</span> <span class="token function">write</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>
allow hello_se_dt devpts:chr_file <span class="token punctuation">{</span> <span class="token builtin class-name">read</span> <span class="token function">write</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>
allow hello_se_dt hello_se_dev_t:file <span class="token punctuation">{</span> <span class="token builtin class-name">read</span> <span class="token function">write</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>
allow hello_se_dt shell:fd use<span class="token punctuation">;</span>
</pre><p>&#x8FD9;&#x91CC;&#x5C31;&#x4F1A;&#x8F93;&#x51FA;&#x76F8;&#x5E94;&#x7684;&#x6743;&#x9650;&#x89C4;&#x5219;,&#x6211;&#x4EEC;&#x5C06;&#x5176;&#x6DFB;&#x52A0;&#x5230;&#x6E90;&#x7801;&#x4E2D; hello_se.te &#x540E;&#x9762;&#x5373;&#x53EF;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token comment"># &#x8FDB;&#x7A0B;&#x5BF9;&#x5E94;&#x7684;&#x7C7B;&#x578B;</span>
<span class="token builtin class-name">type</span>  hello_se_dt, domain<span class="token punctuation">;</span>
<span class="token comment"># &#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;&#x5BF9;&#x5E94;&#x7684;&#x7C7B;&#x578B;</span>
<span class="token builtin class-name">type</span>  hello_se_dt_exec, exec_type, vendor_file_type, file_type<span class="token punctuation">;</span>
<span class="token comment">#&#x8868;&#x793A;&#x8BE5;&#x7A0B;&#x5E8F;&#x5982;&#x679C;&#x4ECE; init &#x8FDB;&#x7A0B;&#x542F;&#x52A8; hello_seandroid_dt_exec&#xFF0C;&#x5176;&#x5B89;&#x5168;&#x4E0A;&#x4E0B;&#x6587;&#x7684; domain &#x90E8;&#x5206;&#x4ECE; init &#x8F6C;&#x5316;&#x4E3A; hello_seandroid_dt</span>
init_daemon_domain<span class="token punctuation">(</span>hello_se_dt<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">#&#x4ECE; shell &#x542F;&#x52A8; type &#x4E3A; hello_seandroid_dt_exec &#x7684;&#x53EF;&#x6267;&#x884C;&#x7A0B;&#x5E8F;&#xFF0C;&#x5176;&#x5BF9;&#x5E94;&#x8FDB;&#x7A0B;&#x7684; domain &#x4E3A; hello_seandroid_dt</span>
domain_auto_trans<span class="token punctuation">(</span>shell, hello_se_dt_exec, hello_se_dt<span class="token punctuation">)</span><span class="token punctuation">;</span>

allow hello_se_dt adbd:unix_stream_socket <span class="token punctuation">{</span> <span class="token builtin class-name">read</span> <span class="token function">write</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>
allow hello_se_dt devpts:chr_file <span class="token punctuation">{</span> <span class="token builtin class-name">read</span> <span class="token function">write</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>
allow hello_se_dt hello_se_dev_t:file <span class="token punctuation">{</span> <span class="token builtin class-name">read</span> <span class="token function">write</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>
allow hello_se_dt shell:fd use<span class="token punctuation">;</span>
</pre><p>&#x518D;&#x6B21;&#x7F16;&#x8BD1;&#x8FD0;&#x884C;&#x7CFB;&#x7EDF;&#xFF0C;&#x5373;&#x53EF;&#x6B63;&#x5E38;&#x4F7F;&#x7528; helloseandroid &#x7A0B;&#x5E8F;</p>
<h2 class="mume-header" id="%E7%AC%AC%E5%8D%81%E7%AB%A0-%E6%B7%BB%E5%8A%A0%E5%BC%80%E6%9C%BA%E8%87%AA%E5%90%AF%E5%8A%A8-shell-%E8%84%9A%E6%9C%AC">&#x7B2C;&#x5341;&#x7AE0; &#x6DFB;&#x52A0;&#x5F00;&#x673A;&#x81EA;&#x542F;&#x52A8; Shell &#x811A;&#x672C;</h2>

<p>&#x5F88;&#x591A;&#x65F6;&#x5019;&#xFF0C;&#x6211;&#x4EEC;&#x60F3;&#x5728;&#x7CFB;&#x7EDF;&#x542F;&#x52A8;&#x7684;&#x65F6;&#x5019;&#x5E72;&#x4E00;&#x4E9B;&#x201C;&#x79C1;&#x6D3B;&#x201D;&#xFF0C;&#x8FD9;&#x4E2A;&#x65F6;&#x5019;&#xFF0C;&#x6211;&#x4EEC;&#x5C31;&#x53EF;&#x4EE5;&#x6DFB;&#x52A0;&#x5F00;&#x673A;&#x81EA;&#x542F;&#x52A8;&#x7684;&#x811A;&#x672C;&#x6765;&#x5B8C;&#x6210;&#x3002;&#x4E0B;&#x9762;&#x6211;&#x4EEC;&#x4ECB;&#x7ECD;&#x4E00;&#x4E2A;&#x7B80;&#x5355;&#x7684;&#x793A;&#x4F8B;&#xFF1A;</p>
<p>&#x5728; <code>device/Jelly/Rice14</code> &#x76EE;&#x5F55;&#x4E0B;&#x6DFB;&#x52A0;&#x5982;&#x4E0B;&#x7684;&#x6587;&#x4EF6;&#x4E0E;&#x6587;&#x4EF6;&#x5939;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">initscript
&#x251C;&#x2500;&#x2500; Android.bp
&#x251C;&#x2500;&#x2500; initscript.rc
&#x2514;&#x2500;&#x2500; initscript.sh

sepolicy    <span class="token comment">#&#x90E8;&#x5206;&#x6587;&#x4EF6;&#x4E3A; seandroid &#x5165;&#x95E8;&#x6DFB;&#x52A0;&#x7684;&#x5185;&#x5BB9;</span>
&#x251C;&#x2500;&#x2500; device.te      
&#x251C;&#x2500;&#x2500; file_contexts
&#x251C;&#x2500;&#x2500; hello_se.te
&#x2514;&#x2500;&#x2500; initscript.te
</pre><p><a href="http://initscript.sh">initscript.sh</a> &#x662F;&#x4E00;&#x4E2A;&#x7B80;&#x5355;&#x7684; shell &#x811A;&#x672C;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token shebang important">#!/vendor/bin/sh</span>

<span class="token builtin class-name">echo</span> <span class="token string">&quot;this is init script&quot;</span>
log -t initscript <span class="token string">&quot;this is initscript!&quot;</span> <span class="token comment">#&#x6253; log</span>
</pre><p>&#x9700;&#x8981;&#x6CE8;&#x610F;&#x7684;&#x662F; shebang &#x7684;&#x5185;&#x5BB9;&#x662F; <code>#!/vendor/bin/sh</code>&#x3002;</p>
<p>initscript.rc &#x7684;&#x5185;&#x5BB9;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="rc" class="language-rc"><code>service initscript /vendor/bin/initscript
    class main
    user root
    group root system
    oneshot
</code></pre><ul>
<li>class main &#x6307;&#x660E;&#x5F53;&#x524D;&#x670D;&#x52A1;&#x65F6;&#x7CFB;&#x7EDF;&#x7684;&#x57FA;&#x672C;&#x670D;&#x52A1;,&#x4FDD;&#x8BC1;&#x4E86;&#x7CFB;&#x7EDF;&#x542F;&#x52A8;&#x65F6;&#xFF0C;&#x4F1A;&#x542F;&#x52A8;&#x8FD9;&#x4E2A;&#x670D;&#x52A1;</li>
<li>oneshot &#x8868;&#x793A;&#x670D;&#x52A1;&#x53EA;&#x6267;&#x884C;&#x4E00;&#x6B21;</li>
</ul>
<p>Android.bp &#x7684;&#x5185;&#x5BB9;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="json" class="language-json">cc_prebuilt_binary <span class="token punctuation">{</span>
    name<span class="token operator">:</span> <span class="token string">&quot;initscript&quot;</span><span class="token punctuation">,</span>
    srcs<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;initscript.sh&quot;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
    init_rc<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;initscript.rc&quot;</span><span class="token punctuation">]</span><span class="token punctuation">,</span> 
    strip<span class="token operator">:</span> <span class="token punctuation">{</span>
        none<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    vendor<span class="token operator">:</span> <span class="token boolean">true</span>
<span class="token punctuation">}</span>

</pre><p>&#x63A5;&#x7740;&#x662F;&#x914D;&#x7F6E; selinux&#xFF1A;</p>
<p>initscript.te &#x7684;&#x5185;&#x5BB9;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="te" class="language-te"><code>type initscript_dt, domain;
type initscript_dt_exec, exec_type, vendor_file_type, file_type;

init_daemon_domain(initscript_dt)
domain_auto_trans(shell, initscript_dt_exec, initscript_dt);
</code></pre><p>file_contexts &#x4E2D;&#x6DFB;&#x52A0;&#x5982;&#x4E0B;&#x5185;&#x5BB9;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="te" class="language-te"><code>/vendor/bin/initscript          u:object_r:initscript_dt_exec:s0
</code></pre><p>&#x6700;&#x540E;&#x4FEE;&#x6539; <code>device/Jelly/Rice14/Rice14.mk</code>&#xFF1A;</p>
<pre data-role="codeBlock" data-info="Makefile" class="language-makefile">PRODUCT_PACKAGES <span class="token operator">+=</span> \
    helloseandroid \
    initscript

BOARD_SEPOLICY_DIRS <span class="token operator">+=</span> \
    device/Jelly/Rice14/sepolicy
</pre><p>&#x63A5;&#x7740;&#x7F16;&#x8BD1;&#x7CFB;&#x7EDF;&#xFF0C;&#x542F;&#x52A8;&#x6A21;&#x62DF;&#x5668;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="Makefile" class="language-makefile">source build/envsetup.sh
lunch Rice14-userdebug
make -j16
emulator
</pre><p>&#x63A5;&#x7740;&#x6211;&#x4EEC;&#x67E5;&#x770B; log&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">logcat <span class="token operator">|</span> <span class="token function">grep</span> initscript

04-08 <span class="token number">23</span>:34:06.250  <span class="token number">1600</span>  <span class="token number">1600</span> W initscript: <span class="token assign-left variable">type</span><span class="token operator">=</span><span class="token number">1400</span> audit<span class="token punctuation">(</span><span class="token number">0.0</span>:6<span class="token punctuation">)</span>: avc: denied <span class="token punctuation">{</span> execute_no_trans <span class="token punctuation">}</span> <span class="token keyword keyword-for">for</span> <span class="token assign-left variable">path</span><span class="token operator">=</span><span class="token string">&quot;/vendor/bin/toybox_vendor&quot;</span> <span class="token assign-left variable">dev</span><span class="token operator">=</span><span class="token string">&quot;dm-1&quot;</span> <span class="token assign-left variable">ino</span><span class="token operator">=</span><span class="token number">205</span> <span class="token assign-left variable">scontext</span><span class="token operator">=</span>u:r:initscript_dt:s0 <span class="token assign-left variable">tcontext</span><span class="token operator">=</span>u:object_r:vendor_toolbox_exec:s0 <span class="token assign-left variable">tclass</span><span class="token operator">=</span>file <span class="token assign-left variable">permissive</span><span class="token operator">=</span><span class="token number">0</span>
</pre><p>&#x9519;&#x8BEF;&#x4FE1;&#x606F;&#xFF0C;&#x63D0;&#x793A;&#x6211;&#x4EEC;&#x7F3A;&#x5C11;&#x6743;&#x9650;&#xFF0C;&#x6309;&#x7167;&#x4E4B;&#x524D;&#x4ECB;&#x7ECD;&#x7684;&#x65B9;&#x6CD5;&#x4F7F;&#x7528; audit2allow &#x547D;&#x4EE4;&#xFF0C;&#x53D1;&#x73B0;&#x5E76;&#x6CA1;&#x6709;&#x751F;&#x6210;&#x7F3A;&#x5931;&#x7684;&#x6743;&#x9650;&#x3002;&#x90A3;&#x600E;&#x4E48;&#x529E;&#xFF1F;&#x770B;&#x62A5;&#x9519;&#x4FE1;&#x606F;&#x55BD;&#xFF1A;</p>
<p>&#x62A5;&#x9519;&#x4FE1;&#x606F;&#x7684;&#x610F;&#x601D;&#x662F;&#xFF1A;&#x5F53; initscript_dt &#x6267;&#x884C;&#x5B89;&#x5168;&#x4E0A;&#x4E0B;&#x6587;&#x4E3A; <code>u:object_r:vendor_toolbox_exec:s0</code> &#x7684; <code>/vendor/bin/toybox_vendor</code> &#x65F6;&#xFF0C;&#x7F3A;&#x5C11; execute_no_trans &#x6743;&#x9650;&#x3002;</p>
<p>&#x4EC0;&#x4E48;&#x610F;&#x601D;&#x5462;&#xFF1F;</p>
<p>&#x6211;&#x4EEC;&#x5148;&#x770B;&#x4E0B; <code>/vendor/bin/toybox_vendor</code> &#x6587;&#x4EF6;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token comment">#&#x5207;&#x6362;&#x4E3A; root</span>
<span class="token function">su</span> 
<span class="token comment">#&#x5E26; x &#x6743;&#x9650;&#xFF0C;&#x662F;&#x4E00;&#x4E2A;&#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;</span>
-rwxr-xr-x <span class="token number">1</span> root shell <span class="token number">503304</span> <span class="token number">2023</span>-04-08 <span class="token number">23</span>:04 /vendor/bin/toybox_vendor
<span class="token comment">#&#x4E0D;&#x5E26;&#x53C2;&#x6570;&#x6267;&#x884C;&#x4E00;&#x4E0B;</span>
/vendor/bin/toybox_vendor                                                                                            
acpi base64 <span class="token function">basename</span> <span class="token function">bc</span> blkid blockdev <span class="token function">cal</span> <span class="token function">cat</span> chattr chcon <span class="token function">chgrp</span>
<span class="token function">chmod</span> <span class="token function">chown</span> <span class="token function">chroot</span> chrt <span class="token function">cksum</span> <span class="token function">clear</span> <span class="token function">cmp</span> <span class="token function">comm</span> <span class="token function">cp</span> cpio <span class="token function">cut</span> <span class="token function">date</span> <span class="token function">dd</span> devmem
<span class="token function">df</span> <span class="token function">diff</span> <span class="token function">dirname</span> <span class="token function">dmesg</span> dos2unix <span class="token function">du</span> <span class="token builtin class-name">echo</span> <span class="token function">egrep</span> <span class="token function">env</span> <span class="token function">expand</span> <span class="token function">expr</span> fallocate
<span class="token boolean">false</span> <span class="token function">fgrep</span> <span class="token function">file</span> <span class="token function">find</span> flock <span class="token function">fmt</span> <span class="token function">free</span> freeramdisk fsfreeze fsync getconf
getenforce getfattr <span class="token function">grep</span> <span class="token function">groups</span> gunzip <span class="token function">gzip</span> <span class="token function">head</span> <span class="token builtin class-name">help</span> <span class="token function">hostname</span> hwclock
i2cdetect i2cdump i2cget i2cset <span class="token function">iconv</span> <span class="token function">id</span> <span class="token function">ifconfig</span> inotifyd insmod
<span class="token function">install</span> ionice iorenice iotop <span class="token function">kill</span> <span class="token function">killall</span> <span class="token function">ln</span> load_policy log <span class="token function">logname</span>
losetup <span class="token function">ls</span> lsattr lsmod <span class="token function">lsof</span> lspci lsusb makedevs md5sum microcom
<span class="token function">mkdir</span> <span class="token function">mkfifo</span> <span class="token function">mknod</span> <span class="token function">mkswap</span> mktemp modinfo modprobe <span class="token function">more</span> <span class="token function">mount</span> mountpoint
<span class="token function">mv</span> nbd-client <span class="token function">nc</span> netcat <span class="token function">netstat</span> <span class="token function">nice</span> <span class="token function">nl</span> <span class="token function">nohup</span> nproc nsenter od partprobe
<span class="token function">paste</span> patch pgrep pidof <span class="token function">ping</span> ping6 pivot_root <span class="token function">pkill</span> pmap <span class="token function">printenv</span>
<span class="token builtin class-name">printf</span> prlimit <span class="token function">ps</span> <span class="token builtin class-name">pwd</span> pwdx readlink realpath <span class="token function">renice</span> restorecon <span class="token function">rev</span>
rfkill <span class="token function">rm</span> <span class="token function">rmdir</span> rmmod runcon <span class="token function">sed</span> sendevent <span class="token function">seq</span> setenforce setfattr
setprop setsid sha1sum sha224sum sha256sum sha384sum sha512sum <span class="token function">sleep</span>
<span class="token function">sort</span> <span class="token function">split</span> start <span class="token function">stat</span> stop strings stty swapoff <span class="token function">swapon</span> <span class="token function">sync</span> sysctl
<span class="token function">tac</span> <span class="token function">tail</span> <span class="token function">tar</span> taskset <span class="token function">tee</span> <span class="token function">time</span> <span class="token function">timeout</span> <span class="token function">top</span> <span class="token function">touch</span> <span class="token function">tr</span> <span class="token function">traceroute</span> traceroute6
<span class="token boolean">true</span> truncate <span class="token function">tty</span> tunctl <span class="token builtin class-name">ulimit</span> <span class="token function">umount</span> <span class="token function">uname</span> <span class="token function">uniq</span> unix2dos unlink
unshare <span class="token function">uptime</span> usleep <span class="token function">uudecode</span> <span class="token function">uuencode</span> uuidgen vconfig <span class="token function">vmstat</span> <span class="token function">watch</span>
</pre><p>&#x4ECE;&#x4EE5;&#x4E0A;&#x7684;&#x64CD;&#x4F5C;&#x53EF;&#x4EE5;&#x770B;&#x51FA; toybox_vendor &#x662F;&#x4E00;&#x4E2A;&#x547D;&#x4EE4;&#x96C6;&#x5408;&#xFF0C;&#x6211;&#x4EEC;&#x5E38;&#x7528;&#x7684; shell &#x547D;&#x4EE4;&#x5747;&#x4F1A;&#x901A;&#x8FC7; toybox_vendor &#x6765;&#x6267;&#x884C;&#x3002;</p>
<p>&#x518D;&#x56DE;&#x5230;&#x6743;&#x9650;&#x90A3;&#x91CC;&#xFF0C;&#x6211;&#x4EEC;&#x7684;&#x811A;&#x672C;&#x8C03;&#x7528;&#x4E86; echo log &#x4E24;&#x4E2A;&#x547D;&#x4EE4;&#xFF0C;&#x8FD9;&#x4E24;&#x4E2A;&#x547D;&#x4EE4;&#x4F1A;&#x901A;&#x8FC7;&#x6267;&#x884C; toybox_vendor &#x6765;&#x5B9E;&#x73B0;&#xFF0C;&#x5F53;&#x6267;&#x884C; toybox_vendor &#x65F6;&#xFF0C;&#x6211;&#x4EEC;&#x5C31;&#x9700;&#x8981; toybox_vendor &#x7684;&#x6253;&#x5F00;&#xFF0C;&#x8BFB;&#x53D6;&#xFF0C;&#x6267;&#x884C;&#x6743;&#x9650;&#xFF0C;&#x4EE5;&#x53CA;&#x914D;&#x7F6E; domain &#x8F6C;&#x6362;&#xFF08;A &#x7A0B;&#x5E8F;&#x5230; B &#x7A0B;&#x5E8F;&#x90FD;&#x9700;&#x8981;&#x914D;&#x7F6E;&#x57DF;&#x8F6C;&#x6362;&#xFF09;&#x3002; domain &#x8F6C;&#x6362;&#x53EF;&#x4EE5;&#x7B80;&#x5355;&#x914D;&#x7F6E;&#x6267;&#x884C;&#x65F6;&#x4E0D;&#x8F6C;&#x6362; execute_no_trans &#x5373;&#x53EF;&#xFF0C;&#x7EFC;&#x4E0A;&#xFF0C;&#x6211;&#x4EEC;&#x5728; initscript.te &#x4E2D;&#x6DFB;&#x52A0;&#x5982;&#x4E0B;&#x6743;&#x9650;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">allow initscript_dt vendor_toolbox_exec:file <span class="token punctuation">{</span> <span class="token builtin class-name">read</span> <span class="token function">open</span> execute execute_no_trans <span class="token punctuation">}</span><span class="token punctuation">;</span>
</pre><p>&#x63A5;&#x7740;&#x518D;&#x6B21;&#x7F16;&#x8BD1;&#x7CFB;&#x7EDF;&#xFF0C;&#x542F;&#x52A8;&#x6A21;&#x62DF;&#x5668;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="Makefile" class="language-makefile">source build/envsetup.sh
lunch Rice14-userdebug
make -j16
emulator
</pre><p>&#x8FDB;&#x5165; adb shell &#x67E5;&#x770B;&#x4FE1;&#x606F;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230409095814.png" alt></p>
<p>&#x542F;&#x52A8;&#x65F6;&#x6253;&#x7684; log&#xFF0C;&#x4EE5;&#x53CA;&#x542F;&#x52A8;&#x76F8;&#x5173;&#x7684;&#x5C5E;&#x6027;&#x503C;&#x5747;&#x6B63;&#x5E38;&#xFF0C;&#x8BC1;&#x660E;&#x6211;&#x4EEC;&#x6DFB;&#x52A0;&#x7684;&#x811A;&#x672C;&#x6267;&#x884C;&#x6210;&#x529F;&#x4E86;&#x3002;</p>
<h2 class="mume-header" id="%E7%AC%AC%E5%8D%81%E4%B8%80%E7%AB%A0-%E5%A6%82%E4%BD%95%E9%98%85%E8%AF%BB%E7%B3%BB%E7%BB%9F%E6%BA%90%E7%A0%81-cc-%E7%AF%87">&#x7B2C;&#x5341;&#x4E00;&#x7AE0; &#x5982;&#x4F55;&#x9605;&#x8BFB;&#x7CFB;&#x7EDF;&#x6E90;&#x7801; C/C++ &#x7BC7;</h2>

<h3 class="mume-header" id="1-%E5%B7%A5%E5%85%B7%E7%AF%87">1. &#x5DE5;&#x5177;&#x7BC7;</h3>

<p>&#x5BF9;&#x4E8E; Android &#x7CFB;&#x7EDF;&#x6E90;&#x7801;&#x4E2D;&#x7684; C/C++ &#x4EE3;&#x7801;&#xFF0C;CLion &#x662F;&#x4E00;&#x4E2A;&#x4E0D;&#x9519;&#x7684;&#x5DE5;&#x5177;&#x3002;</p>
<p>&#x8F83;&#x65B0;&#x7248;&#x672C;&#x7684; Android &#x6E90;&#x7801;&#x652F;&#x6301;&#x4F7F;&#x7528; AIDEgen &#x8C03;&#x7528; Clion &#x67E5;&#x770B; C/C++ &#x4EE3;&#x7801;&#x3002;&#x4F46;&#x662F;&#xFF0C;&#x5BF9;&#x4E8E;&#x6211;&#x4EEC;&#x5B66;&#x4E60;&#x4F7F;&#x7528;&#x7684; Android10 &#x662F;&#x4E0D;&#x652F;&#x6301;&#x7684;&#x3002;&#x4E0D;&#x8FC7;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x5176;&#x4ED6;&#x529E;&#x6CD5;&#x5B9E;&#x73B0; Clion &#x67E5;&#x770B; C/C++ &#x4EE3;&#x7801;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token comment"># &#x51C6;&#x5907;&#x5DE5;&#x4F5C;</span>
<span class="token builtin class-name">source</span> build/envsetup.sh
lunch aosp_x86_64-eng <span class="token comment">#&#x9009;&#x62E9;&#x4E00;&#x4E2A;&#x5408;&#x9002;&#x7684; Product</span>
<span class="token builtin class-name">export</span> <span class="token assign-left variable">SOONG_GEN_CMAKEFILES</span><span class="token operator">=</span><span class="token number">1</span>
<span class="token builtin class-name">export</span> <span class="token assign-left variable">SOONG_GEN_CMAKEFILES_DEBUG</span><span class="token operator">=</span><span class="token number">1</span>
<span class="token function">make</span> -j16
</pre><p>&#x63A5;&#x7740;&#x6211;&#x4EEC;&#x5C31;&#x53EF;&#x4EE5;&#x4F7F;&#x7528; Clion &#x6253;&#x5F00;&#x6211;&#x4EEC;&#x7684;&#x4EE3;&#x7801;&#x4E86;&#x3002;</p>
<p>&#x5047;&#x8BBE;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x770B; SurfaceFlinger &#x76F8;&#x5173;&#x4EE3;&#x7801;:</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token comment">#&#x7CFB;&#x7EDF;&#x6E90;&#x7801;&#x76EE;&#x5F55;&#x4E0B;&#x641C;&#x7D22;</span>
<span class="token function">find</span> <span class="token builtin class-name">.</span> -name <span class="token string">&quot;SurfaceFlinger*&quot;</span>
./frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
./frameworks/native/services/surfaceflinger/SurfaceFlingerProperties.cpp
./frameworks/native/services/surfaceflinger/SurfaceFlinger.h
./frameworks/native/services/surfaceflinger/SurfaceFlingerProperties.h
./frameworks/native/services/surfaceflinger/SurfaceFlingerFactory.h
<span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span>.
</pre><p>&#x8FD9;&#x91CC;&#x6211;&#x4EEC;&#x77E5;&#x9053; SurfaceFlinger &#x5B9A;&#x4E49;&#x5728; <code>frameworks/native/services</code> &#x76EE;&#x5F55;:</p>
<p>&#x63A5;&#x7740;&#x6211;&#x4EEC;&#x6253;&#x5F00; Clion&#xFF0C;&#x70B9;&#x51FB; Open&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230512043810.png" alt></p>
<p>&#x9009;&#x62E9; <code>out/development/ide/clion/frameworks/native</code> &#x76EE;&#x5F55;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230512044216.png" alt></p>
<p>&#x8FD9;&#x6837;&#x6211;&#x4EEC;&#x5C31;&#x53EF;&#x4EE5;&#x4F7F;&#x7528; CLion &#x67E5;&#x770B;&#x7CFB;&#x7EDF;&#x6E90;&#x7801;&#x4E86;&#xFF0C;&#x9700;&#x8981;&#x6CE8;&#x610F;&#x7684;&#x662F;&#x6211;&#x4EEC;&#x7684;&#x6E90;&#x7801;&#x9700;&#x8981;&#x5728; External Libraries &#x4E2D;&#x67E5;&#x770B;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230512044745.png" alt></p>
<p>&#x6211;&#x4EEC;&#x4E5F;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x70B9;&#x51FB; Change Project Root &#x6309;&#x94AE;&#x8C03;&#x6574;&#x76EE;&#x5F55;&#x7ED3;&#x6784;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230512054649.png" alt></p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230512054745.png" alt></p>
<h3 class="mume-header" id="2-%E6%89%8B%E6%AE%B5%E7%AF%87">2. &#x624B;&#x6BB5;&#x7BC7;</h3>

<p>&#x9605;&#x8BFB;&#x6E90;&#x7801;&#x4E3B;&#x8981;&#x4E24;&#x4E2A;&#x624B;&#x6BB5;&#xFF1A;</p>
<ul>
<li>&#x6253;&#x5370; Log + &#x6253;&#x5370;&#x8C03;&#x7528;&#x5806;&#x6808;</li>
<li>&#x4F7F;&#x7528; CLion &#x8C03;&#x8BD5;</li>
</ul>
<p>&#x8FD9;&#x91CC;&#x6211;&#x4EEC;&#x4FEE;&#x6539; SurfaceFlinger &#x7684;&#x4E3B;&#x51FD;&#x6570; main_surfaceflinger.cpp &#x6765;&#x6F14;&#x793A;&#x6253;&#x5370; Log &#x548C;&#x6253;&#x5370;&#x8C03;&#x7528;&#x5806;&#x6808;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="c++" class="language-cpp"><span class="token comment">//log&#x7684;&#x5934;&#x6587;&#x4EF6;</span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&quot;log/log.h&quot;</span></span>
<span class="token comment">//&#x76F4;&#x63A5; define LOG_TAG &#x4F1A;&#x62A5;&#x5DF2;&#x5B9A;&#x4E49;&#x9519;&#x8BEF;&#xFF0C;&#x56E0;&#x4E3A; SurFaceFlinger &#x6A21;&#x5757;&#x7684; Android.bp &#x5DF2;&#x7ECF;&#x5B9A;&#x4E49;&#x4E86; LOG_Tag</span>
<span class="token comment">//&#x4E0B;&#x9762;&#x8FD9;&#x6837;&#x5B9A;&#x4E49;&#x5C31;&#x4E0D;&#x4F1A;&#x51FA;&#x9519;&#x4E86;</span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">ifdef</span> <span class="token expression">LOG_TAG</span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">undef</span> <span class="token expression">LOG_TAG</span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">define</span> <span class="token macro-name">LOG_TAG</span> <span class="token string">&quot;yuandaima_sf&quot;</span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">endif</span></span>

<span class="token comment">//&#x6253;&#x5370;&#x5806;&#x6808;&#x7684;&#x5934;&#x6587;&#x4EF6;</span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;utils/CallStack.h&gt;</span></span>

<span class="token comment">//&#x5728; main &#x51FD;&#x6570;&#x4E2D;&#x6253;&#x5370;&#x4FE1;&#x606F;</span>

<span class="token keyword keyword-int">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token keyword keyword-int">int</span><span class="token punctuation">,</span> <span class="token keyword keyword-char">char</span><span class="token operator">*</span><span class="token operator">*</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>

    <span class="token comment">//&#x6253;&#x5370;&#x65E5;&#x5FD7;</span>
    <span class="token function">ALOGD</span><span class="token punctuation">(</span><span class="token string">&quot;surfaceflinger is starting&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token comment">//&#x6253;&#x5370;&#x5806;&#x6808;</span>
    android<span class="token double-colon punctuation">::</span>CallStack <span class="token function">callStack</span><span class="token punctuation">(</span>LOG_TAG<span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token comment">//&#x7701;&#x7565;&#x540E;&#x9762;&#x7684;&#x4EE3;&#x7801;</span>
    <span class="token comment">//......</span>
<span class="token punctuation">}</span>
</pre><p>&#x4FEE;&#x6539; /frameworks/native/services/surfaceflinger/Android.bp,&#x6DFB;&#x52A0; CallStack &#x7684;&#x5E93;&#x4F9D;&#x8D56;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230512060159.png" alt></p>
<p>&#x63A5;&#x7740;&#x6211;&#x4EEC;&#x91CD;&#x65B0;&#x7F16;&#x8BD1;&#x4EE3;&#x7801;&#xFF0C;&#x542F;&#x52A8;&#x6A21;&#x62DF;&#x5668;&#xFF0C;&#x8FDB;&#x5165; adb shell&#xFF0C;&#x67E5;&#x770B; log&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">rice14:/ <span class="token comment"># logcat | grep yuandaima_sf</span>
05-11 09:54:10.291  <span class="token number">1531</span>  <span class="token number">1531</span> D yuandaima_sf: surfaceflinger is starting

05-11 09:54:10.296  <span class="token number">1531</span>  <span class="token number">1531</span> D yuandaima_sf: <span class="token comment">#00 pc 00000000000030a1  /system/bin/surfaceflinger (main+65)</span>
05-11 09:54:10.296  <span class="token number">1531</span>  <span class="token number">1531</span> D yuandaima_sf: <span class="token comment">#01 pc 000000000008a985  /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+117)</span>
</pre><p>&#x901A;&#x8FC7; log &#x4FE1;&#x606F;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x77E5;&#x9053;&#x7A0B;&#x5E8F;&#x7684;&#x8FD0;&#x884C;&#x72B6;&#x6001;&#x548C;&#x8FD0;&#x884C;&#x8FC7;&#x7A0B;&#x4E2D;&#x7684;&#x5173;&#x952E;&#x53C2;&#x6570;&#x3002;&#x901A;&#x8FC7;&#x8C03;&#x7528;&#x6808;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x77E5;&#x9053;&#x51FD;&#x6570;&#x7684;&#x6267;&#x884C;&#x6D41;&#x7A0B;&#x3002;</p>
<p>&#x6211;&#x4EEC;&#x8FD8;&#x53EF;&#x4EE5;&#x901A;&#x8FC7; Clion &#x6765;&#x8C03;&#x8BD5; C/C++ &#x4EE3;&#x7801;:</p>
<p>&#x8FD9;&#x91CC;&#x4EE5;&#x8C03;&#x8BD5; service_manager.c &#x4E3A;&#x4F8B;&#xFF1A;</p>
<p>&#x6211;&#x4EEC;&#x5728;&#x5982;&#x4E0B;&#x4F4D;&#x7F6E;&#x6253;&#x5370;&#x597D;&#x65AD;&#x70B9;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230512054931.png" alt></p>
<p>&#x63A5;&#x7740;&#x914D;&#x7F6E;&#x8FDC;&#x7A0B;&#x8C03;&#x8BD5;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230512055029.png" alt></p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230512055121.png" alt></p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230512055156.png" alt></p>
<p>&#x8FD9;&#x6837;&#x6211;&#x4EEC;&#x7684; Clion &#x5C31;&#x914D;&#x7F6E;&#x597D;&#x4E86;&#x3002;</p>
<p>&#x63A5;&#x7740;&#x6211;&#x4EEC;&#x67E5;&#x770B; servicemanage &#x8FDB;&#x7A0B;&#x7684; pid&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">adb shell <span class="token function">ps</span> -A <span class="token operator">|</span> <span class="token function">grep</span> servicemanager 
system        <span class="token number">1406</span>     <span class="token number">1</span>   <span class="token number">14116</span>   <span class="token number">5532</span> binder_ioctl        <span class="token number">0</span> S servicemanager
system        <span class="token number">1407</span>     <span class="token number">1</span>   <span class="token number">21764</span>   <span class="token number">9772</span> SyS_epoll_wait      <span class="token number">0</span> S hwservicemanager
system        <span class="token number">1408</span>     <span class="token number">1</span>   <span class="token number">14816</span>   <span class="token number">2584</span> binder_ioctl        <span class="token number">0</span> S vndservicemanage
</pre><p>servicemanager &#x7684; pid &#x4E3A; 1406&#xFF0C;&#x63A5;&#x7740;&#x5728;&#x6A21;&#x62DF;&#x5668;&#x4E0A;&#x5F00;&#x542F; gdbserver&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">adb forward tcp:1235 tcp:1235
adb shell gdbserver64 :1235 --attach <span class="token number">1406</span>
</pre><p>&#x63A5;&#x7740;&#x70B9;&#x51FB; Clion &#x53F3;&#x4E0A;&#x89D2;&#x7684; debug &#x6309;&#x94AE;&#x5C31;&#x8FDB;&#x5165; debug &#x73AF;&#x5883;&#x4E86;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230512055546.png" alt></p>
<p>&#x8FD9;&#x6837;&#x6211;&#x4EEC;&#x5C31;&#x53EF;&#x4EE5;&#x5F00;&#x59CB;&#x8C03;&#x8BD5; C/C++ &#x4EE3;&#x7801;&#x4E86;&#x3002;</p>
<h2 class="mume-header" id="%E7%AC%AC%E5%8D%81%E4%BA%8C%E7%AB%A0-%E5%A6%82%E4%BD%95%E9%98%85%E8%AF%BB%E7%B3%BB%E7%BB%9F%E6%BA%90%E7%A0%81-java-%E7%AF%87">&#x7B2C;&#x5341;&#x4E8C;&#x7AE0; &#x5982;&#x4F55;&#x9605;&#x8BFB;&#x7CFB;&#x7EDF;&#x6E90;&#x7801; Java &#x7BC7;</h2>

<h3 class="mume-header" id="1-%E5%B7%A5%E5%85%B7%E7%AF%87--aidegen--android-studio">1. &#x5DE5;&#x5177;&#x7BC7; &#x2014;&#x2014; AIDEGen + Android Studio</h3>

<p>AIDEGen&#xFF0C;&#x6211;&#x53EB;&#x5B83; &#x201C;&#x7231;&#x5F97;&#x8DDF;&#x201D;&#xFF0C;&#x5927;&#x6982;&#x662F; Android10 &#x4E2D;&#xFF0C;google &#x63A8;&#x51FA;&#x7684;&#x4E00;&#x4E2A;&#x5DE5;&#x5177;&#xFF0C;&#x7528;&#x4E8E;&#x65B9;&#x4FBF;&#x5F00;&#x53D1;&#x8005;&#x4F7F;&#x7528; IDE &#x6765;&#x67E5;&#x770B;&#x548C;&#x4FEE;&#x6539;&#x7CFB;&#x7EDF;&#x6E90;&#x7801;&#x3002;AIDEGen + Android Studio &#x975E;&#x5E38;&#x9002;&#x5408;&#x7528;&#x4E8E;&#x9605;&#x8BFB;&#x4E0E;&#x4FEE;&#x6539; Android &#x7CFB;&#x7EDF; Java &#x4EE3;&#x7801;&#x3002;</p>
<p>&#x4F7F;&#x7528; &#x201C;&#x7231;&#x5F97;&#x8DDF;&#x201D; &#x4E4B;&#x524D;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x505A;&#x4E00;&#x4E9B;&#x51C6;&#x5907;&#x5DE5;&#x4F5C;&#xFF0C;&#x7F16;&#x8BD1; sdk&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token builtin class-name">source</span> build/envsetup.sh
lunch sdk-eng
<span class="token comment"># or</span>
<span class="token comment">#lunch sdk-userdebug</span>
<span class="token comment"># or</span>
<span class="token comment">#lunch sdk-user</span>
<span class="token function">make</span> sdk
</pre><p>&#x63A5;&#x7740;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x53BB; google &#x5B98;&#x65B9;&#x4E0B;&#x8F7D; Android Studio&#xFF0C;&#x5E76;&#x5C06;&#x5176;&#x653E;&#x5230; /opt &#x76EE;&#x5F55;&#x4E0B;&#x3002;&#x8FD9;&#x63A8;&#x8350;&#x4F7F;&#x7528; 3.6.3 &#x7248;&#x672C;&#xFF0C;&#x4E0E;&#x6211;&#x4EEC;&#x7684; Android10_r41 &#x66F4;&#x4E3A;&#x5339;&#x914D;&#x3002;</p>
<p>&#x63A5;&#x4E0B;&#x6765;&#xFF0C;&#x9009;&#x62E9;&#x6211;&#x4EEC;&#x7684;&#x76EE;&#x6807; Product&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token builtin class-name">source</span> build/envsetup.sh
lunch aosp_x86_64-eng  <span class="token comment">#&#x4E5F;&#x53EF;&#x4EE5;&#x662F;&#x5176;&#x4ED6; product</span>
</pre><p>&#x505A;&#x597D;&#x4EE5;&#x4E0A;&#x51C6;&#x5907;&#x5DE5;&#x4F5C;&#x540E;&#xFF0C;&#x6211;&#x4EEC;&#x5C31;&#x53EF;&#x4EE5;&#x6253;&#x5F00;&#x7CFB;&#x7EDF;&#x6A21;&#x5757;&#x4E86;&#xFF0C;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token comment"># Settings &#x662F;&#x7CFB;&#x7EDF;&#x5E94;&#x7528; &#x8BBE;&#x7F6E;</span>
aidegen Settings -i s  <span class="token comment"># -i &#x8868;&#x793A;&#x4F7F;&#x7528;ide&#xFF0C;s &#x8868;&#x793A; Android Studio</span>

<span class="token comment"># &#x4E5F;&#x53EF;&#x4EE5;&#x6253;&#x5F00;&#x4E00;&#x4E2A;&#x8DEF;&#x5F84;&#xFF0C;&#x786E;&#x4FDD;&#x8FD9;&#x4E2A;&#x8DEF;&#x5F84;&#x4E0B;&#x6709; Android.bp &#x6216;&#x8005; Android.mk &#x5373;&#x53EF;</span>
aidegen frameworks/base/services -i s
</pre><p>&#x7A0D;&#x4F5C;&#x7B49;&#x5F85;&#xFF0C;Android Studio &#x5C31;&#x6253;&#x5F00;&#x4E86;&#xFF0C;&#x4E0D;&#x8FC7;&#x73B0;&#x5728;&#x8FD8;&#x4E0D;&#x80FD;&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#xFF0C;&#x6211;&#x4EEC;&#x8FD8;&#x9700;&#x8981;&#x505A;&#x4E00;&#x4E9B;&#x57FA;&#x672C;&#x7684;&#x914D;&#x7F6E;:</p>
<p>Android Studio &#x6253;&#x5F00;&#x540E;&#xFF0C;&#x53F3;&#x4E0B;&#x89D2;&#x4F1A;&#x51FA;&#x73B0;&#x4E00;&#x4E2A;&#x63D0;&#x793A;&#x6846;&#xFF08;&#x5982;&#x679C;&#x6CA1;&#x6709;&#x51FA;&#x73B0;&#xFF0C;&#x70B9;&#x51FB; file -&gt; Invalidate Caches -&gt; Invalidate and Restart&#xFF09;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230330232504.png" alt></p>
<p>&#x70B9;&#x51FB; Configure&#xFF0C;&#x51FA;&#x73B0;&#x4EE5;&#x4E0B;&#x754C;&#x9762;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230330232744.png" alt></p>
<p>&#x70B9;&#x51FB; ok &#x5373;&#x53EF;&#x3002;</p>
<p>&#x63A5;&#x7740;&#x914D;&#x7F6E; jdk &#x548C; sdk&#xFF0C;&#x70B9;&#x51FB; file -&gt; Project Structure&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230330233341.png" alt></p>
<p>&#x63A5;&#x7740;&#x70B9;&#x51FB; + &#x53F7;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230330233429.png" alt></p>
<p>&#x70B9;&#x51FB; <code>Add JDK</code>&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230330233429.png" alt></p>
<p>&#x9009;&#x62E9;&#x6E90;&#x7801;&#x4E0B;&#x7684; <code>prebuilts/jdk/jdk9/linux-x86</code>,&#x7136;&#x540E;&#x70B9;&#x51FB; ok:</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230330233925.png" alt></p>
<p>&#x63A5;&#x7740;&#x5C06; name &#x4FEE;&#x6539;&#x4E3A; aosp10-jdk9&#xFF0C;&#x7136;&#x540E;&#x70B9;&#x51FB;&#x53F3;&#x4E0B;&#x89D2; apply:</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230330234053.png" alt></p>
<p>&#x63A5;&#x7740;&#x70B9;&#x51FB; + &#x53F7;&#xFF0C;&#x6DFB;&#x52A0; Android SDK&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230330234337.png" alt></p>
<p>&#x9009;&#x62E9;&#x7CFB;&#x7EDF;&#x6E90;&#x7801;&#x76EE;&#x5F55;&#x4E0B;&#x7684; <code>out/host/linux-x86/sdk/sdk/android-sdk_eng.zzh0838_linux-x86</code> (&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x6587;&#x4EF6;&#x5939;&#x7684;&#x540D;&#x5B57;&#x548C;&#x4F60;&#x7684;&#x7528;&#x6237;&#x540D;&#x76F8;&#x5173;&#xFF0C;&#x4F60;&#x7684;&#x548C;&#x6211;&#x7684;&#x53EF;&#x80FD;&#x4E0D;&#x4E00;&#x6837;)&#xFF0C;&#x7136;&#x540E;&#x70B9;&#x51FB; ok&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230330235615.png" alt></p>
<p>&#x63A5;&#x7740; Java SDK &#x9009;&#x62E9;&#x521A;&#x521A;&#x6DFB;&#x52A0;&#x7684; aosp10-jdk9&#xFF0C;&#x70B9;&#x51FB; ok&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230330235743.png" alt></p>
<p>&#x63A5;&#x7740;&#xFF0C;&#x4FEE;&#x6539; skd &#x7684;&#x540D;&#x5B57;&#x4E3A; aosp10-android-sdk29:</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230330235943.png" alt></p>
<p>&#x70B9;&#x51FB; ok &#x5373;&#x53EF;&#x3002;</p>
<p>&#x63A5;&#x7740;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x914D;&#x7F6E;&#x9879;&#x76EE;&#x7684; sdk&#xFF0C;&#x70B9;&#x51FB; file -&gt; Project Structure&#xFF0C;&#x70B9;&#x51FB;&#x5DE6;&#x4FA7; Project&#xFF0C;&#x53F3;&#x4FA7; SDK &#x9009;&#x9879;&#x9009;&#x62E9; aosp10-android-sdk&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230331000336.png" alt></p>
<p>&#x70B9;&#x51FB;&#x5DE6;&#x4FA7; Modules&#xFF0C;&#x4E2D;&#x95F4;&#x9009;&#x62E9; Settings&#xFF0C;&#x53F3;&#x4FA7; Module SDK &#x9009;&#x62E9; Project SDK&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230331000444.png" alt></p>
<p>&#x63A5;&#x7740;&#xFF0C;&#x4E2D;&#x95F4;&#x9009;&#x62E9; dependencies-Settings&#xFF0C;&#x53F3;&#x4FA7; Module SDK &#x9009;&#x62E9; Project SDK&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230331000540.png" alt></p>
<p>&#x6700;&#x540E;&#x70B9;&#x51FB; apply&#xFF0C;&#x9879;&#x76EE;&#x5F00;&#x59CB;&#x91CD;&#x65B0;&#x7D22;&#x5F15;&#xFF0C;&#x9879;&#x76EE;&#x5185;&#x7EDD;&#x5927;&#x90E8;&#x5206;&#x7C7B;&#x65B9;&#x6CD5;&#x53D8;&#x91CF;&#x5747;&#x53EF;&#x6B63;&#x786E;&#x8DF3;&#x8F6C;&#x3002;</p>
<p>&#x81F3;&#x6B64;&#xFF0C;&#x914D;&#x7F6E;&#x5B8C;&#x6210;&#x3002;</p>
<h3 class="mume-header" id="2-%E6%89%8B%E6%AE%B5%E7%AF%87--java-%E6%BA%90%E7%A0%81%E7%9A%84%E9%98%85%E8%AF%BB">2. &#x624B;&#x6BB5;&#x7BC7; &#x2014;&#x2014; Java &#x6E90;&#x7801;&#x7684;&#x9605;&#x8BFB;</h3>

<p>Java &#x6E90;&#x7801;&#x6211;&#x4EEC;&#x4E00;&#x822C;&#x901A;&#x8FC7;&#x4EE5;&#x4E0B;&#x4E24;&#x79CD;&#x65B9;&#x6CD5;&#x9605;&#x8BFB;&#xFF1A;</p>
<ol>
<li>Log + &#x6253;&#x5370;&#x8C03;&#x7528;&#x6808;</li>
<li>AIDEGen + Android Studio + &#x65AD;&#x70B9;&#x8C03;&#x8BD5;</li>
</ol>
<p>&#x9488;&#x5BF9;&#x542F;&#x52A8;&#x76F8;&#x5173;&#x7684;&#x6E90;&#x7801;&#xFF0C;&#x4E00;&#x822C;&#x662F;&#x4F7F;&#x7528;&#x7B2C;&#x4E00;&#x79CD;&#x65B9;&#x6CD5;&#x9605;&#x8BFB;&#xFF0C;&#x63A5;&#x4E0B;&#x6765;&#x6211;&#x4EEC;&#x6765;&#x770B;&#x770B;&#x5982;&#x4F55;&#x9605;&#x8BFB;&#x7CFB;&#x7EDF;&#x542F;&#x52A8;&#x8FC7;&#x7A0B;&#x4E2D;&#x7684;&#x91CD;&#x8981;&#x8FDB;&#x7A0B; SystemServer&#xFF1A;</p>
<p>&#x9996;&#x5148;&#x627E;&#x5230; SystemServer&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token comment">#&#x6E90;&#x7801;&#x6839;&#x76EE;&#x5F55;&#x4E0B;</span>
<span class="token builtin class-name">cd</span> frameworks

<span class="token function">find</span> <span class="token builtin class-name">.</span> -name <span class="token string">&quot;SystemServer*&quot;</span>
./base/cmds/svc/src/com/android/commands/svc/SystemServerCommand.java
./base/services/java/com/android/server/SystemServer.java
./base/services/core/java/com/android/server/SystemServerInitThreadPool.java

<span class="token comment"># aidengen &#x6253;&#x5F00;</span>
aidegen frameworks/base/services
</pre><p>&#x5728; Android Studio &#x4E2D;&#x6211;&#x4EEC;&#x6253;&#x5F00; SystemServer.java&#xFF0C;&#x627E;&#x5230; main &#x65B9;&#x6CD5;&#xFF0C;&#x5E76;&#x6DFB;&#x52A0;&#x4E0B;&#x9762;&#x7684;&#x4EE3;&#x7801;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="java" class="language-java"><span class="token keyword keyword-public">public</span> <span class="token keyword keyword-static">static</span> <span class="token keyword keyword-void">void</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span> args<span class="token punctuation">)</span> <span class="token punctuation">{</span>

    <span class="token comment">//&#x901A;&#x8FC7;&#x6253;&#x5370; log &#x4E86;&#x89E3;&#x7A0B;&#x5E8F;&#x7684;&#x8FD0;&#x884C;&#x72B6;&#x51B5;</span>
    <span class="token class-name">Log</span><span class="token punctuation">.</span><span class="token function">d</span><span class="token punctuation">(</span><span class="token string">&quot;yuandaima&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;SystemServer is starting&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//&#x901A;&#x8FC7;&#x6253;&#x5370;&#x5806;&#x6808;&#x4E86;&#x89E3;&#x65B9;&#x6CD5;&#x7684;&#x8C03;&#x7528;&#x8DEF;&#x5F84;</span>
    <span class="token function">printStackTrace</span><span class="token punctuation">(</span><span class="token class-name">Thread</span><span class="token punctuation">.</span><span class="token function">currentThread</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        
    <span class="token keyword keyword-new">new</span> <span class="token class-name">SystemServer</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">run</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

 

<span class="token comment">//&#x6253;&#x5370;&#x8C03;&#x7528;&#x5806;&#x6808;&#x7684;&#x65B9;&#x6CD5;</span>
<span class="token keyword keyword-public">public</span> <span class="token keyword keyword-static">static</span> <span class="token keyword keyword-void">void</span> <span class="token function">printStackTrace</span><span class="token punctuation">(</span><span class="token class-name">Thread</span> thread<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword keyword-for">for</span> <span class="token punctuation">(</span><span class="token class-name">StackTraceElement</span> e <span class="token operator">:</span> thread<span class="token punctuation">.</span><span class="token function">getStackTrace</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token class-name">Log</span><span class="token punctuation">.</span><span class="token function">d</span><span class="token punctuation">(</span><span class="token string">&quot;yuandaima&quot;</span><span class="token punctuation">,</span> e<span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
  
</pre><p>&#x63A5;&#x7740;&#x6211;&#x4EEC;&#x7F16;&#x8BD1;&#x7CFB;&#x7EDF;&#xFF0C;&#x5F00;&#x542F;&#x6A21;&#x62DF;&#x5668;&#xFF0C;&#x7136;&#x540E;&#x83B7;&#x53D6;&#x65E5;&#x5FD7;&#x4FE1;&#x606F;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash">rice14:/ <span class="token comment"># logcat | grep &quot;yuandaima&quot;</span>
05-10 <span class="token number">21</span>:37:04.719  <span class="token number">1641</span>  <span class="token number">1641</span> D yuandaima: SystemServer is starting
05-10 <span class="token number">21</span>:37:04.720  <span class="token number">1641</span>  <span class="token number">1641</span> D yuandaima: dalvik.system.VMStack.getThreadStackTrace<span class="token punctuation">(</span>Native Method<span class="token punctuation">)</span>
05-10 <span class="token number">21</span>:37:04.721  <span class="token number">1641</span>  <span class="token number">1641</span> D yuandaima: java.lang.Thread.getStackTrace<span class="token punctuation">(</span>Thread.java:1720<span class="token punctuation">)</span>
05-10 <span class="token number">21</span>:37:04.721  <span class="token number">1641</span>  <span class="token number">1641</span> D yuandaima: com.android.server.SystemServer.printStackTrace<span class="token punctuation">(</span>SystemServer.java:350<span class="token punctuation">)</span>
05-10 <span class="token number">21</span>:37:04.721  <span class="token number">1641</span>  <span class="token number">1641</span> D yuandaima: com.android.server.SystemServer.main<span class="token punctuation">(</span>SystemServer.java:362<span class="token punctuation">)</span>
05-10 <span class="token number">21</span>:37:04.721  <span class="token number">1641</span>  <span class="token number">1641</span> D yuandaima: java.lang.reflect.Method.invoke<span class="token punctuation">(</span>Native Method<span class="token punctuation">)</span>
05-10 <span class="token number">21</span>:37:04.721  <span class="token number">1641</span>  <span class="token number">1641</span> D yuandaima: com.android.internal.os.RuntimeInit<span class="token variable">$MethodAndArgsCaller</span>.run<span class="token punctuation">(</span>RuntimeInit.java:492<span class="token punctuation">)</span>
05-10 <span class="token number">21</span>:37:04.721  <span class="token number">1641</span>  <span class="token number">1641</span> D yuandaima: com.android.internal.os.ZygoteInit.main<span class="token punctuation">(</span>ZygoteInit.java:908<span class="token punctuation">)</span>
</pre><p>&#x901A;&#x8FC7;&#x6253;&#x65E5;&#x5FD7;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x4E86;&#x89E3;&#x7CFB;&#x7EDF;&#x7A0B;&#x5E8F;&#x7684;&#x8FD0;&#x884C;&#x72B6;&#x51B5;&#x4EE5;&#x53CA;&#x4E00;&#x4E9B;&#x5173;&#x952E;&#x53C2;&#x6570;&#xFF0C;&#x901A;&#x8FC7;&#x8C03;&#x7528;&#x5806;&#x6808;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x4E86;&#x89E3;&#x7A0B;&#x5E8F;&#x8FD0;&#x884C;&#x8FC7;&#x7A0B;&#x4E2D;&#x65B9;&#x6CD5;&#x7684;&#x4E00;&#x4E2A;&#x8C03;&#x7528;&#x6D41;&#x7A0B;&#x3002;</p>
<p>&#x975E;&#x542F;&#x52A8;&#x76F8;&#x5173;&#x7684;&#x6E90;&#x7801;&#xFF0C;&#x901A;&#x5E38;&#x7ED3;&#x5408;&#x4E24;&#x79CD;&#x65B9;&#x6CD5;&#x6765;&#x9605;&#x8BFB;&#x3002;&#x63A5;&#x4E0B;&#x6765;&#x6211;&#x4EEC;&#x770B;&#x770B;&#x5982;&#x4F55;&#x65AD;&#x70B9;&#x8C03;&#x8BD5;&#x7CFB;&#x7EDF; App&#xFF1A;</p>
<p>&#x9996;&#x5148;&#xFF0C;&#x6211;&#x4EEC;&#x5F00;&#x4E00;&#x4E2A;&#x65B0;&#x7684;&#x7EC8;&#x7AEF;&#xFF0C;&#x6253;&#x5F00;&#x6A21;&#x62DF;&#x5668;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="bash" class="language-bash"><span class="token builtin class-name">source</span> build/envsetup.sh
lunch aosp_x86_64-eng
emulator
</pre><p>&#x63A5;&#x7740;&#x6211;&#x4EEC;&#x5728; Settings/AndroidManifest.xml &#x67E5;&#x627E;&#x5230; Settings App &#x7684;&#x9996; Activity &#x4E3A; SettingsHomepageActivity&#xFF0C;&#x6211;&#x4EEC;&#x5728;&#x5176; onCreate &#x51FA;&#x6253;&#x4E00;&#x4E2A;&#x65AD;&#x70B9;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230331001249.png" alt></p>
<p>&#x63A5;&#x7740;&#x5728; Android &#x6A21;&#x62DF;&#x5668;&#x4E2D;&#x6253;&#x5F00; Settings &#x5E94;&#x7528;&#x3002;</p>
<p>&#x63A5;&#x7740;&#x70B9;&#x51FB; android studio &#x7684; debug &#x6309;&#x94AE;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230331001845.png" alt></p>
<p>&#x5728;&#x5F39;&#x51FA;&#x7684;&#x7A97;&#x53E3;&#x4E2D;&#xFF0C;&#x4F9D;&#x6B21;&#x9009;&#x62E9; Settings &#x548C; com.android.settings,&#x7136;&#x540E;&#x70B9;&#x51FB; ok&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230331002002.png" alt></p>
<p>&#x5728;&#x6A21;&#x62DF;&#x5668;&#x4E2D;&#xFF0C;&#x70B9;&#x51FB;&#x8FD4;&#x56DE;&#x952E;&#xFF0C;&#x518D;&#x6B21;&#x8FDB;&#x5165; Settings &#x5E94;&#x7528;&#xFF0C;&#x5373;&#x53EF;&#x8FDB;&#x5165;&#x8C03;&#x8BD5;&#x754C;&#x9762;&#xFF1A;</p>
<p><img src="https://gitee.com/stingerzou/pic-bed/raw/master/img/20230331002134.png" alt></p>
<p>&#x63A5;&#x7740;&#x6211;&#x4EEC;&#x5C31;&#x53EF;&#x4EE5;&#x987A;&#x5229;&#x7684;&#x8FDB;&#x884C;&#x8C03;&#x8BD5;&#x4E86;&#x3002;</p>

      </div>
      
      
    
    
    
    
    
    
    
    
  
    </body></html>